summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/auto.pro5
-rw-r--r--tests/auto/declarative/declarative.pro108
-rw-r--r--tests/auto/declarative/examples/tst_examples.cpp11
-rw-r--r--tests/auto/declarative/graphicswidgets/data/graphicswidgets.qml1
-rw-r--r--tests/auto/declarative/graphicswidgets/tst_graphicswidgets.cpp10
-rw-r--r--tests/auto/declarative/layouts/data/layouts.qml1
-rw-r--r--tests/auto/declarative/layouts/tst_layouts.cpp33
-rw-r--r--tests/auto/declarative/parserstress/tst_parserstress.cpp8
-rw-r--r--tests/auto/declarative/qdeclarativeanchors/data/anchors.qml (renamed from tests/auto/declarative/qmlgraphicsanchors/data/anchors.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeanchors/data/centerin.qml (renamed from tests/auto/declarative/qmlgraphicsanchors/data/centerin.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeanchors/data/crash1.qml (renamed from tests/auto/declarative/qmlgraphicsanchors/data/crash1.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeanchors/data/fill.qml (renamed from tests/auto/declarative/qmlgraphicsanchors/data/fill.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeanchors/data/loop1.qml (renamed from tests/auto/declarative/qmlgraphicsanchors/data/loop1.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeanchors/data/loop2.qml (renamed from tests/auto/declarative/qmlgraphicsanchors/data/loop2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeanchors/data/margins.qml (renamed from tests/auto/declarative/qmlgraphicsanchors/data/margins.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeanchors/qdeclarativeanchors.pro6
-rw-r--r--tests/auto/declarative/qdeclarativeanchors/tst_qdeclarativeanchors.cpp448
-rw-r--r--tests/auto/declarative/qdeclarativeanimatedimage/data/colors.gif (renamed from tests/auto/declarative/qmlgraphicsanimatedimage/data/colors.gif)bin505 -> 505 bytes
-rw-r--r--tests/auto/declarative/qdeclarativeanimatedimage/data/colors.qml (renamed from tests/auto/declarative/qmlgraphicsanimatedimage/data/colors.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeanimatedimage/data/stickman.gif (renamed from tests/auto/declarative/qmlgraphicsanimatedimage/data/stickman.gif)bin164923 -> 164923 bytes
-rw-r--r--tests/auto/declarative/qdeclarativeanimatedimage/data/stickman.qml (renamed from tests/auto/declarative/qmlgraphicsanimatedimage/data/stickman.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeanimatedimage/data/stickmanpause.qml (renamed from tests/auto/declarative/qmlgraphicsanimatedimage/data/stickmanpause.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeanimatedimage/data/stickmanstopped.qml (renamed from tests/auto/declarative/qmlgraphicsanimatedimage/data/stickmanstopped.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeanimatedimage/qdeclarativeanimatedimage.pro7
-rw-r--r--tests/auto/declarative/qdeclarativeanimatedimage/tst_qdeclarativeanimatedimage.cpp191
-rw-r--r--tests/auto/declarative/qdeclarativeanimations/data/attached.qml (renamed from tests/auto/declarative/qmlanimations/data/attached.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeanimations/data/badproperty1.qml (renamed from tests/auto/declarative/qmlanimations/data/badproperty1.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeanimations/data/badproperty2.qml (renamed from tests/auto/declarative/qmlanimations/data/badproperty2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeanimations/data/badtype1.qml (renamed from tests/auto/declarative/qmlanimations/data/badtype1.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeanimations/data/badtype2.qml (renamed from tests/auto/declarative/qmlanimations/data/badtype2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeanimations/data/badtype3.qml (renamed from tests/auto/declarative/qmlanimations/data/badtype3.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeanimations/data/badtype4.qml (renamed from tests/auto/declarative/qmlanimations/data/badtype4.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeanimations/data/dontAutoStart.qml (renamed from tests/auto/declarative/qmlanimations/data/dontAutoStart.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeanimations/data/dontStart.qml (renamed from tests/auto/declarative/qmlanimations/data/dontStart.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeanimations/data/dontStart2.qml (renamed from tests/auto/declarative/qmlanimations/data/dontStart2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeanimations/data/dotproperty.qml (renamed from tests/auto/declarative/qmlanimations/data/dotproperty.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeanimations/data/mixedtype1.qml (renamed from tests/auto/declarative/qmlanimations/data/mixedtype1.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeanimations/data/mixedtype2.qml (renamed from tests/auto/declarative/qmlanimations/data/mixedtype2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeanimations/data/properties.qml (renamed from tests/auto/declarative/qmlanimations/data/properties.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeanimations/data/properties2.qml (renamed from tests/auto/declarative/qmlanimations/data/properties2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeanimations/data/properties3.qml (renamed from tests/auto/declarative/qmlanimations/data/properties3.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeanimations/data/properties4.qml (renamed from tests/auto/declarative/qmlanimations/data/properties4.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeanimations/data/properties5.qml (renamed from tests/auto/declarative/qmlanimations/data/properties5.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeanimations/data/propertiesTransition.qml (renamed from tests/auto/declarative/qmlanimations/data/propertiesTransition.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeanimations/data/propertiesTransition2.qml (renamed from tests/auto/declarative/qmlanimations/data/propertiesTransition2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeanimations/data/propertiesTransition3.qml (renamed from tests/auto/declarative/qmlanimations/data/propertiesTransition3.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeanimations/data/propertiesTransition4.qml (renamed from tests/auto/declarative/qmlanimations/data/propertiesTransition4.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeanimations/data/propertiesTransition5.qml (renamed from tests/auto/declarative/qmlanimations/data/propertiesTransition5.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeanimations/data/propertiesTransition6.qml (renamed from tests/auto/declarative/qmlanimations/data/propertiesTransition6.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeanimations/data/valuesource.qml (renamed from tests/auto/declarative/qmlanimations/data/valuesource.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeanimations/data/valuesource2.qml (renamed from tests/auto/declarative/qmlanimations/data/valuesource2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeanimations/qdeclarativeanimations.pro6
-rw-r--r--tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp672
-rw-r--r--tests/auto/declarative/qdeclarativebehaviors/data/binding.qml (renamed from tests/auto/declarative/qmlbehaviors/data/binding.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativebehaviors/data/color.qml (renamed from tests/auto/declarative/qmlbehaviors/data/color.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativebehaviors/data/cpptrigger.qml (renamed from tests/auto/declarative/qmlbehaviors/data/cpptrigger.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativebehaviors/data/disabled.qml (renamed from tests/auto/declarative/qmlbehaviors/data/disabled.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativebehaviors/data/dontStart.qml (renamed from tests/auto/declarative/qmlbehaviors/data/dontStart.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativebehaviors/data/empty.qml (renamed from tests/auto/declarative/qmlbehaviors/data/empty.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativebehaviors/data/explicit.qml (renamed from tests/auto/declarative/qmlbehaviors/data/explicit.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativebehaviors/data/groupProperty.qml (renamed from tests/auto/declarative/qmlbehaviors/data/groupProperty.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativebehaviors/data/groupProperty2.qml (renamed from tests/auto/declarative/qmlbehaviors/data/groupProperty2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativebehaviors/data/loop.qml (renamed from tests/auto/declarative/qmlbehaviors/data/loop.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativebehaviors/data/nonSelecting2.qml (renamed from tests/auto/declarative/qmlbehaviors/data/nonSelecting2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativebehaviors/data/parent.qml (renamed from tests/auto/declarative/qmlbehaviors/data/parent.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativebehaviors/data/reassignedAnimation.qml (renamed from tests/auto/declarative/qmlbehaviors/data/reassignedAnimation.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativebehaviors/data/scripttrigger.qml (renamed from tests/auto/declarative/qmlbehaviors/data/scripttrigger.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativebehaviors/data/simple.qml (renamed from tests/auto/declarative/qmlbehaviors/data/simple.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativebehaviors/qdeclarativebehaviors.pro6
-rw-r--r--tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp301
-rw-r--r--tests/auto/declarative/qdeclarativebinding/data/test-binding.qml (renamed from tests/auto/declarative/qmlbinding/data/test-binding.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativebinding/data/test-binding2.qml (renamed from tests/auto/declarative/qmlbinding/data/test-binding2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativebinding/qdeclarativebinding.pro8
-rw-r--r--tests/auto/declarative/qdeclarativebinding/tst_qdeclarativebinding.cpp107
-rw-r--r--tests/auto/declarative/qdeclarativeborderimage/data/colors-round.sci (renamed from tests/auto/declarative/qmlgraphicsborderimage/data/colors-round.sci)0
-rw-r--r--tests/auto/declarative/qdeclarativeborderimage/data/colors.png (renamed from tests/auto/declarative/visual/qmlgraphicsborderimage/content/colors.png)bin1655 -> 1655 bytes
-rw-r--r--tests/auto/declarative/qdeclarativeborderimage/data/invalid.sci (renamed from tests/auto/declarative/qmlgraphicsborderimage/data/invalid.sci)0
-rw-r--r--tests/auto/declarative/qdeclarativeborderimage/qdeclarativeborderimage.pro9
-rw-r--r--tests/auto/declarative/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp351
-rw-r--r--tests/auto/declarative/qdeclarativeconnection/data/test-connection.qml10
-rw-r--r--tests/auto/declarative/qdeclarativeconnection/data/test-connection2.qml3
-rw-r--r--tests/auto/declarative/qdeclarativeconnection/data/test-connection3.qml3
-rw-r--r--tests/auto/declarative/qdeclarativeconnection/data/trimming.qml10
-rw-r--r--tests/auto/declarative/qdeclarativeconnection/qdeclarativeconnection.pro8
-rw-r--r--tests/auto/declarative/qdeclarativeconnection/tst_qdeclarativeconnection.cpp135
-rw-r--r--tests/auto/declarative/qdeclarativecontext/qdeclarativecontext.pro6
-rw-r--r--tests/auto/declarative/qdeclarativecontext/tst_qdeclarativecontext.cpp434
-rw-r--r--tests/auto/declarative/qdeclarativedatetimeformatter/qdeclarativedatetimeformatter.pro5
-rw-r--r--tests/auto/declarative/qdeclarativedatetimeformatter/tst_qdeclarativedatetimeformatter.cpp150
-rw-r--r--tests/auto/declarative/qdeclarativedebug/qdeclarativedebug.pro7
-rw-r--r--tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp843
-rw-r--r--tests/auto/declarative/qdeclarativedebugclient/qdeclarativedebugclient.pro7
-rw-r--r--tests/auto/declarative/qdeclarativedebugclient/tst_qdeclarativedebugclient.cpp157
-rw-r--r--tests/auto/declarative/qdeclarativedebugservice/qdeclarativedebugservice.pro7
-rw-r--r--tests/auto/declarative/qdeclarativedebugservice/tst_qdeclarativedebugservice.cpp190
-rw-r--r--tests/auto/declarative/qdeclarativedom/data/MyComponent.qml (renamed from tests/auto/declarative/qmldom/data/MyComponent.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativedom/data/MyItem.qml (renamed from tests/auto/declarative/qmldom/data/MyItem.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativedom/data/importdir/Bar.qml (renamed from tests/auto/declarative/qmldom/data/importdir/Bar.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativedom/data/importlib/sublib/qmldir/Foo.qml (renamed from tests/auto/declarative/qmldom/data/importlib/sublib/qmldir/Foo.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativedom/data/top.qml (renamed from tests/auto/declarative/qmldom/data/top.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativedom/qdeclarativedom.pro7
-rw-r--r--tests/auto/declarative/qdeclarativedom/tst_qdeclarativedom.cpp1313
-rw-r--r--tests/auto/declarative/qdeclarativeeasefollow/data/easefollow1.qml (renamed from tests/auto/declarative/qmleasefollow/data/easefollow1.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeeasefollow/data/easefollow2.qml (renamed from tests/auto/declarative/qmleasefollow/data/easefollow2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeeasefollow/data/easefollow3.qml (renamed from tests/auto/declarative/qmleasefollow/data/easefollow3.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeeasefollow/qdeclarativeeasefollow.pro8
-rw-r--r--tests/auto/declarative/qdeclarativeeasefollow/tst_qdeclarativeeasefollow.cpp122
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/ConstantsOverrideBindings.qml (renamed from tests/auto/declarative/qmlecmascript/data/ConstantsOverrideBindings.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/CustomObject.qml (renamed from tests/auto/declarative/qmlecmascript/data/CustomObject.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/MethodsObject.qml (renamed from tests/auto/declarative/qmlecmascript/data/MethodsObject.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/NestedTypeTransientErrors.qml (renamed from tests/auto/declarative/qmlecmascript/data/NestedTypeTransientErrors.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/ScopeObject.qml (renamed from tests/auto/declarative/qmlecmascript/data/ScopeObject.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/TypeForDynamicCreation.qml (renamed from tests/auto/declarative/qmlecmascript/data/TypeForDynamicCreation.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/aliasPropertyAndBinding.qml (renamed from tests/auto/declarative/qmlecmascript/data/aliasPropertyAndBinding.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/assignBasicTypes.2.qml (renamed from tests/auto/declarative/qmlecmascript/data/assignBasicTypes.2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/assignBasicTypes.qml (renamed from tests/auto/declarative/qmlecmascript/data/assignBasicTypes.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/attachedProperty.qml (renamed from tests/auto/declarative/qmlecmascript/data/attachedProperty.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/bindingLoop.qml (renamed from tests/auto/declarative/qmlecmascript/data/bindingLoop.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/boolPropertiesEvaluateAsBool.1.qml (renamed from tests/auto/declarative/qmlecmascript/data/boolPropertiesEvaluateAsBool.1.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/boolPropertiesEvaluateAsBool.2.qml (renamed from tests/auto/declarative/qmlecmascript/data/boolPropertiesEvaluateAsBool.2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/bug.1.qml (renamed from tests/auto/declarative/qmlecmascript/data/bug.1.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/compositePropertyType.qml (renamed from tests/auto/declarative/qmlecmascript/data/compositePropertyType.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/constantsOverrideBindings.1.qml (renamed from tests/auto/declarative/qmlecmascript/data/constantsOverrideBindings.1.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/constantsOverrideBindings.2.qml (renamed from tests/auto/declarative/qmlecmascript/data/constantsOverrideBindings.2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/constantsOverrideBindings.3.qml (renamed from tests/auto/declarative/qmlecmascript/data/constantsOverrideBindings.3.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/declarativeToString.qml (renamed from tests/auto/declarative/qmlecmascript/data/qmlToString.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/deferredProperties.qml (renamed from tests/auto/declarative/qmlecmascript/data/deferredProperties.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/deletedObject.qml (renamed from tests/auto/declarative/qmlecmascript/data/deletedObject.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/dynamicCreation.helper.qml (renamed from tests/auto/declarative/qmlecmascript/data/dynamicCreation.helper.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/dynamicCreation.qml (renamed from tests/auto/declarative/qmlecmascript/data/dynamicCreation.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/dynamicDeletion.qml (renamed from tests/auto/declarative/qmlecmascript/data/dynamicDeletion.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/enums.1.qml (renamed from tests/auto/declarative/qmlecmascript/data/enums.1.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/enums.2.qml (renamed from tests/auto/declarative/qmlecmascript/data/enums.2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/exceptionClearsOnReeval.qml (renamed from tests/auto/declarative/qmlecmascript/data/exceptionClearsOnReeval.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/exceptionProducesWarning.qml (renamed from tests/auto/declarative/qmlecmascript/data/exceptionProducesWarning.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/exceptionProducesWarning2.qml (renamed from tests/auto/declarative/qmlecmascript/data/exceptionProducesWarning2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/extendedObjectPropertyLookup.qml (renamed from tests/auto/declarative/qmlecmascript/data/extendedObjectPropertyLookup.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/extensionObjects.qml (renamed from tests/auto/declarative/qmlecmascript/data/extensionObjects.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/externalScript.1.qml (renamed from tests/auto/declarative/qmlecmascript/data/externalScript.1.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/externalScript.2.js (renamed from tests/auto/declarative/qmlecmascript/data/externalScript.2.js)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/externalScript.2.qml (renamed from tests/auto/declarative/qmlecmascript/data/externalScript.2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/externalScript.3.qml (renamed from tests/auto/declarative/qmlecmascript/data/externalScript.3.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/externalScript.4.qml (renamed from tests/auto/declarative/qmlecmascript/data/externalScript.4.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/externalScript.js (renamed from tests/auto/declarative/qmlecmascript/data/externalScript.js)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/idShortcutInvalidates.1.qml (renamed from tests/auto/declarative/qmlecmascript/data/idShortcutInvalidates.1.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/idShortcutInvalidates.qml (renamed from tests/auto/declarative/qmlecmascript/data/idShortcutInvalidates.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/jsObject.qml (renamed from tests/auto/declarative/qmlecmascript/data/jsObject.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/listProperties.qml (renamed from tests/auto/declarative/qmlecmascript/data/listProperties.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/listToVariant.qml (renamed from tests/auto/declarative/qmlecmascript/data/listToVariant.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/methods.1.qml (renamed from tests/auto/declarative/qmlecmascript/data/methods.1.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/methods.2.qml (renamed from tests/auto/declarative/qmlecmascript/data/methods.2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/methods.3.qml (renamed from tests/auto/declarative/qmlecmascript/data/methods.3.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/methods.4.qml (renamed from tests/auto/declarative/qmlecmascript/data/methods.4.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/methods.5.qml (renamed from tests/auto/declarative/qmlecmascript/data/methods.5.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/multiEngineObject.qml (renamed from tests/auto/declarative/qmlecmascript/data/multiEngineObject.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/nonExistantAttachedObject.qml (renamed from tests/auto/declarative/qmlecmascript/data/nonExistantAttachedObject.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/objectsCompareAsEqual.qml (renamed from tests/auto/declarative/qmlecmascript/data/objectsCompareAsEqual.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/outerBindingOverridesInnerBinding.qml (renamed from tests/auto/declarative/qmlecmascript/data/outerBindingOverridesInnerBinding.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/scope.2.qml (renamed from tests/auto/declarative/qmlecmascript/data/scope.2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/scope.qml (renamed from tests/auto/declarative/qmlecmascript/data/scope.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/scriptAccess.js (renamed from tests/auto/declarative/qmlecmascript/data/scriptAccess.js)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/scriptAccess.qml (renamed from tests/auto/declarative/qmlecmascript/data/scriptAccess.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/scriptErrors.js (renamed from tests/auto/declarative/qmlecmascript/data/scriptErrors.js)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/scriptErrors.qml (renamed from tests/auto/declarative/qmlecmascript/data/scriptErrors.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/selfDeletingBinding.2.qml (renamed from tests/auto/declarative/qmlecmascript/data/selfDeletingBinding.2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/selfDeletingBinding.qml (renamed from tests/auto/declarative/qmlecmascript/data/selfDeletingBinding.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/shutdownErrors.qml (renamed from tests/auto/declarative/qmlecmascript/data/shutdownErrors.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/signalAssignment.1.qml (renamed from tests/auto/declarative/qmlecmascript/data/signalAssignment.1.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/signalAssignment.2.qml (renamed from tests/auto/declarative/qmlecmascript/data/signalAssignment.2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/signalParameterTypes.qml (renamed from tests/auto/declarative/qmlecmascript/data/signalParameterTypes.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/signalTriggeredBindings.qml (renamed from tests/auto/declarative/qmlecmascript/data/signalTriggeredBindings.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/transientErrors.qml (renamed from tests/auto/declarative/qmlecmascript/data/transientErrors.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/undefinedResetsProperty.2.qml (renamed from tests/auto/declarative/qmlecmascript/data/undefinedResetsProperty.2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/undefinedResetsProperty.qml (renamed from tests/auto/declarative/qmlecmascript/data/undefinedResetsProperty.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/valueTypeFunctions.qml (renamed from tests/auto/declarative/qmlecmascript/data/valueTypeFunctions.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/qdeclarativeecmascript.pro10
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp85
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/testtypes.h598
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp1662
-rw-r--r--tests/auto/declarative/qdeclarativeengine/qdeclarativeengine.pro8
-rw-r--r--tests/auto/declarative/qdeclarativeengine/tst_qdeclarativeengine.cpp240
-rw-r--r--tests/auto/declarative/qdeclarativeerror/qdeclarativeerror.pro6
-rw-r--r--tests/auto/declarative/qdeclarativeerror/test.txt (renamed from tests/auto/declarative/qmlerror/test.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativeerror/tst_qdeclarativeerror.cpp242
-rw-r--r--tests/auto/declarative/qdeclarativeflickable/data/flickable01.qml (renamed from tests/auto/declarative/qmlgraphicsflickable/data/flickable01.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeflickable/data/flickable02.qml14
-rw-r--r--tests/auto/declarative/qdeclarativeflickable/data/flickable03.qml14
-rw-r--r--tests/auto/declarative/qdeclarativeflickable/data/flickable04.qml16
-rw-r--r--tests/auto/declarative/qdeclarativeflickable/qdeclarativeflickable.pro8
-rw-r--r--tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp223
-rw-r--r--tests/auto/declarative/qdeclarativeflipable/data/test-flipable.qml (renamed from tests/auto/declarative/qmlgraphicsflipable/data/test-flipable.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeflipable/qdeclarativeflipable.pro8
-rw-r--r--tests/auto/declarative/qdeclarativeflipable/tst_qdeclarativeflipable.cpp113
-rw-r--r--tests/auto/declarative/qdeclarativefontloader/data/dummy.ttf (renamed from tests/auto/declarative/qmlfontloader/data/dummy.ttf)0
-rw-r--r--tests/auto/declarative/qdeclarativefontloader/data/tarzeau_ocr_a.ttf (renamed from tests/auto/declarative/qmlfontloader/data/tarzeau_ocr_a.ttf)bin24544 -> 24544 bytes
-rw-r--r--tests/auto/declarative/qdeclarativefontloader/qdeclarativefontloader.pro8
-rw-r--r--tests/auto/declarative/qdeclarativefontloader/tst_qdeclarativefontloader.cpp156
-rw-r--r--tests/auto/declarative/qdeclarativegridview/data/displaygrid.qml39
-rw-r--r--tests/auto/declarative/qdeclarativegridview/data/gridview-initCurrent.qml (renamed from tests/auto/declarative/qmlgraphicsgridview/data/gridview-initCurrent.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativegridview/data/gridview.qml (renamed from tests/auto/declarative/qmlgraphicsgridview/data/gridview.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativegridview/data/gridview2.qml (renamed from tests/auto/declarative/qmlgraphicsgridview/data/gridview2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativegridview/data/gridview3.qml (renamed from tests/auto/declarative/qmlgraphicsgridview/data/gridview3.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativegridview/data/setindex.qml33
-rw-r--r--tests/auto/declarative/qdeclarativegridview/qdeclarativegridview.pro8
-rw-r--r--tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp1022
-rw-r--r--tests/auto/declarative/qdeclarativeimage/data/colors.png (renamed from tests/auto/declarative/qmlgraphicsimage/data/colors.png)bin1655 -> 1655 bytes
-rw-r--r--tests/auto/declarative/qdeclarativeimage/data/colors1.png (renamed from tests/auto/declarative/qmlgraphicsborderimage/data/colors.png)bin1655 -> 1655 bytes
-rw-r--r--tests/auto/declarative/qdeclarativeimage/qdeclarativeimage.pro9
-rw-r--r--tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp253
-rw-r--r--tests/auto/declarative/qdeclarativeimageprovider/data/exists.png (renamed from tests/auto/declarative/qmlpixmapcache/data/exists.png)bin2738 -> 2738 bytes
-rw-r--r--tests/auto/declarative/qdeclarativeimageprovider/data/exists1.png (renamed from tests/auto/declarative/qmlpixmapcache/data/exists1.png)bin2738 -> 2738 bytes
-rw-r--r--tests/auto/declarative/qdeclarativeimageprovider/data/exists2.png (renamed from tests/auto/declarative/qmlpixmapcache/data/exists2.png)bin2738 -> 2738 bytes
-rw-r--r--tests/auto/declarative/qdeclarativeimageprovider/qdeclarativeimageprovider.pro12
-rw-r--r--tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp166
-rw-r--r--tests/auto/declarative/qdeclarativeinfo/data/NestedObject.qml (renamed from tests/auto/declarative/qmlinfo/data/NestedObject.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeinfo/data/nestedQmlObject.qml (renamed from tests/auto/declarative/qmlinfo/data/nestedQmlObject.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeinfo/data/qmlObject.qml (renamed from tests/auto/declarative/qmlinfo/data/qmlObject.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeinfo/qdeclarativeinfo.pro7
-rw-r--r--tests/auto/declarative/qdeclarativeinfo/tst_qdeclarativeinfo.cpp139
-rw-r--r--tests/auto/declarative/qdeclarativeinstruction/qdeclarativeinstruction.pro6
-rw-r--r--tests/auto/declarative/qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp585
-rw-r--r--tests/auto/declarative/qdeclarativeitem/data/keynavigation.qml (renamed from tests/auto/declarative/qmlgraphicsitem/data/keynavigation.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeitem/data/keys.qml (renamed from tests/auto/declarative/qmlgraphicsitem/data/keys.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeitem/qdeclarativeitem.pro7
-rw-r--r--tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp318
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/Alias.qml (renamed from tests/auto/declarative/qmllanguage/data/Alias.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/Alias2.qml (renamed from tests/auto/declarative/qmllanguage/data/Alias2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/Alias3.qml (renamed from tests/auto/declarative/qmllanguage/data/Alias3.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/Alias4.qml (renamed from tests/auto/declarative/qmllanguage/data/Alias4.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/ComponentComposite.qml (renamed from tests/auto/declarative/qmllanguage/data/ComponentComposite.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/CompositeType.qml (renamed from tests/auto/declarative/qmllanguage/data/CompositeType.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/CompositeType2.qml (renamed from tests/auto/declarative/qmllanguage/data/CompositeType2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/CompositeType3.qml (renamed from tests/auto/declarative/qmllanguage/data/CompositeType3.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/CompositeType4.qml (renamed from tests/auto/declarative/qmllanguage/data/CompositeType4.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/DynamicPropertiesNestedType.qml (renamed from tests/auto/declarative/qmllanguage/data/DynamicPropertiesNestedType.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/HelperAlias.qml (renamed from tests/auto/declarative/qmllanguage/data/HelperAlias.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/I18n.qml (renamed from tests/auto/declarative/qmllanguage/data/I18n.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/I18nType30.qml (renamed from tests/auto/declarative/qmllanguage/data/I18nType30.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/MyComponent.qml (renamed from tests/auto/declarative/qmllanguage/data/MyComponent.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/MyCompositeValueSource.qml (renamed from tests/auto/declarative/qmllanguage/data/MyCompositeValueSource.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/MyContainerComponent.qml (renamed from tests/auto/declarative/qmllanguage/data/MyContainerComponent.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/NestedAlias.qml (renamed from tests/auto/declarative/qmllanguage/data/NestedAlias.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/NestedErrorsType.qml (renamed from tests/auto/declarative/qmllanguage/data/NestedErrorsType.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/OnCompletedType.qml (renamed from tests/auto/declarative/qmllanguage/data/OnCompletedType.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/alias.1.qml (renamed from tests/auto/declarative/qmllanguage/data/alias.1.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/alias.2.qml (renamed from tests/auto/declarative/qmllanguage/data/alias.2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/alias.3.qml (renamed from tests/auto/declarative/qmllanguage/data/alias.3.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/alias.4.qml (renamed from tests/auto/declarative/qmllanguage/data/alias.4.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/alias.5.qml (renamed from tests/auto/declarative/qmllanguage/data/alias.5.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/alias.6.qml (renamed from tests/auto/declarative/qmllanguage/data/alias.6.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/alias.7.qml (renamed from tests/auto/declarative/qmllanguage/data/alias.7.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/alias.8.qml (renamed from tests/auto/declarative/qmllanguage/data/alias.8.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/alias.9.qml (renamed from tests/auto/declarative/qmllanguage/data/alias.9.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/assignBasicTypes.qml (renamed from tests/auto/declarative/qmllanguage/data/assignBasicTypes.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/assignCompositeToType.qml (renamed from tests/auto/declarative/qmllanguage/data/assignCompositeToType.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/assignLiteralSignalProperty.qml (renamed from tests/auto/declarative/qmllanguage/data/assignLiteralSignalProperty.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/assignObjectToSignal.qml (renamed from tests/auto/declarative/qmllanguage/data/assignObjectToSignal.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/assignObjectToVariant.qml (renamed from tests/auto/declarative/qmllanguage/data/assignObjectToVariant.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/assignQmlComponent.qml (renamed from tests/auto/declarative/qmllanguage/data/assignQmlComponent.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/assignSignal.qml (renamed from tests/auto/declarative/qmllanguage/data/assignSignal.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/assignTypeExtremes.qml (renamed from tests/auto/declarative/qmllanguage/data/assignTypeExtremes.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/attachedProperties.qml (renamed from tests/auto/declarative/qmllanguage/data/attachedProperties.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/autoComponentCreation.qml (renamed from tests/auto/declarative/qmllanguage/data/autoComponentCreation.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/autoNotifyConnection.qml6
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/component.1.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/component.1.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/component.1.qml (renamed from tests/auto/declarative/qmllanguage/data/component.1.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/component.2.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/component.2.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/component.2.qml (renamed from tests/auto/declarative/qmllanguage/data/component.2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/component.3.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/component.3.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/component.3.qml (renamed from tests/auto/declarative/qmllanguage/data/component.3.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/component.4.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/component.4.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/component.4.qml (renamed from tests/auto/declarative/qmllanguage/data/component.4.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/component.5.errors.txt1
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/component.5.qml (renamed from tests/auto/declarative/qmllanguage/data/component.5.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/component.6.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/component.6.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/component.6.qml (renamed from tests/auto/declarative/qmllanguage/data/component.6.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/componentCompositeType.qml (renamed from tests/auto/declarative/qmllanguage/data/componentCompositeType.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/cppnamespace.2.qml (renamed from tests/auto/declarative/qmllanguage/data/cppnamespace.2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/cppnamespace.qml (renamed from tests/auto/declarative/qmllanguage/data/cppnamespace.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/crash2.qml (renamed from tests/auto/declarative/qmllanguage/data/crash2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/customParserIdNotAllowed.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/customParserIdNotAllowed.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/customParserIdNotAllowed.qml (renamed from tests/auto/declarative/qmllanguage/data/customParserIdNotAllowed.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/customParserTypes.qml (renamed from tests/auto/declarative/qmllanguage/data/customParserTypes.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/customVariantTypes.qml (renamed from tests/auto/declarative/qmllanguage/data/customVariantTypes.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/declaredPropertyValues.qml (renamed from tests/auto/declarative/qmllanguage/data/declaredPropertyValues.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/defaultGrouped.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/defaultGrouped.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/defaultGrouped.qml (renamed from tests/auto/declarative/qmllanguage/data/defaultGrouped.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/defaultPropertyListOrder.qml (renamed from tests/auto/declarative/qmllanguage/data/defaultPropertyListOrder.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/doubleSignal.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/doubleSignal.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/doubleSignal.qml (renamed from tests/auto/declarative/qmllanguage/data/doubleSignal.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/duplicateIDs.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/duplicateIDs.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/duplicateIDs.qml (renamed from tests/auto/declarative/qmllanguage/data/duplicateIDs.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/dynamicObject.1.qml (renamed from tests/auto/declarative/qmllanguage/data/dynamicObject.1.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/dynamicObjectProperties.qml (renamed from tests/auto/declarative/qmllanguage/data/dynamicObjectProperties.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/dynamicProperties.qml (renamed from tests/auto/declarative/qmllanguage/data/dynamicProperties.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/dynamicPropertiesNested.qml (renamed from tests/auto/declarative/qmllanguage/data/dynamicPropertiesNested.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/dynamicSignalsAndSlots.qml (renamed from tests/auto/declarative/qmllanguage/data/dynamicSignalsAndSlots.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/empty.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/empty.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/empty.qml (renamed from tests/auto/declarative/qmllanguage/data/empty.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/emptySignal.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/emptySignal.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/emptySignal.qml (renamed from tests/auto/declarative/qmllanguage/data/emptySignal.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/failingComponent.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/failingComponent.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/failingComponentTest.qml (renamed from tests/auto/declarative/qmllanguage/data/failingComponentTest.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/fakeDotProperty.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/fakeDotProperty.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/fakeDotProperty.qml (renamed from tests/auto/declarative/qmllanguage/data/fakeDotProperty.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/finalOverride.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/finalOverride.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/finalOverride.qml (renamed from tests/auto/declarative/qmllanguage/data/finalOverride.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/i18nDeclaredPropertyNames.qml (renamed from tests/auto/declarative/qmllanguage/data/i18nDeclaredPropertyNames.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/i18nDeclaredPropertyUse.qml (renamed from tests/auto/declarative/qmllanguage/data/i18nDeclaredPropertyUse.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/i18nNameSpace.qml (renamed from tests/auto/declarative/qmllanguage/data/i18nNameSpace.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/i18nScript.qml (renamed from tests/auto/declarative/qmllanguage/data/i18nScript.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/i18nStrings.qml (renamed from tests/auto/declarative/qmllanguage/data/i18nStrings.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/i18nType.qml (renamed from tests/auto/declarative/qmllanguage/data/i18nType.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/idProperty.qml (renamed from tests/auto/declarative/qmllanguage/data/idProperty.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/importNamespaceConflict.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/importNamespaceConflict.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/importNamespaceConflict.qml (renamed from tests/auto/declarative/qmllanguage/data/importNamespaceConflict.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/importVersionMissingBuiltIn.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/importVersionMissingBuiltIn.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/importVersionMissingBuiltIn.qml (renamed from tests/auto/declarative/qmllanguage/data/importVersionMissingBuiltIn.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/importVersionMissingInstalled.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/importVersionMissingInstalled.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/importVersionMissingInstalled.qml (renamed from tests/auto/declarative/qmllanguage/data/importVersionMissingInstalled.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/inlineQmlComponents.qml (renamed from tests/auto/declarative/qmllanguage/data/inlineQmlComponents.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/interfaceProperty.qml (renamed from tests/auto/declarative/qmllanguage/data/interfaceProperty.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/interfaceQList.qml (renamed from tests/auto/declarative/qmllanguage/data/interfaceQList.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.1.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.1.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.1.qml (renamed from tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.1.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.10.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.10.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.10.qml (renamed from tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.10.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.11.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.11.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.11.qml (renamed from tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.11.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.2.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.2.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.2.qml (renamed from tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.3.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.3.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.3.qml (renamed from tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.3.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.4.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.4.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.4.qml (renamed from tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.4.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.5.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.5.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.5.qml (renamed from tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.5.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.6.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.6.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.6.qml (renamed from tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.6.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.7.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.7.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.7.qml (renamed from tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.7.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.8.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.8.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.8.qml (renamed from tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.8.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.9.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.9.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.9.qml (renamed from tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.9.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.1.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.1.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.1.qml (renamed from tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.1.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.2.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.2.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.2.qml (renamed from tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.3.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.3.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.3.qml (renamed from tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.3.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.4.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.4.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.4.qml (renamed from tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.4.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.5.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.5.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.5.qml (renamed from tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.5.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.6.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.6.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.6.qml (renamed from tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.6.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.7.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.7.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.7.qml (renamed from tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.7.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidID.2.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/invalidID.2.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidID.2.qml (renamed from tests/auto/declarative/qmllanguage/data/invalidID.2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidID.3.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/invalidID.3.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidID.3.qml (renamed from tests/auto/declarative/qmllanguage/data/invalidID.3.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidID.4.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/invalidID.4.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidID.4.qml (renamed from tests/auto/declarative/qmllanguage/data/invalidID.4.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidID.5.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/invalidID.5.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidID.5.qml (renamed from tests/auto/declarative/qmllanguage/data/invalidID.5.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidID.6.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/invalidID.6.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidID.6.qml (renamed from tests/auto/declarative/qmllanguage/data/invalidID.6.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidID.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/invalidID.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidID.qml (renamed from tests/auto/declarative/qmllanguage/data/invalidID.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidImportID.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/invalidImportID.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidImportID.qml (renamed from tests/auto/declarative/qmllanguage/data/invalidImportID.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidRoot.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/invalidRoot.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidRoot.qml (renamed from tests/auto/declarative/qmllanguage/data/invalidRoot.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/InstalledTest.qml (renamed from tests/auto/declarative/qmllanguage/data/lib/com/nokia/installedtest/InstalledTest.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/InstalledTest2.qml (renamed from tests/auto/declarative/qmllanguage/data/lib/com/nokia/installedtest/InstalledTest2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/PrivateType.qml (renamed from tests/auto/declarative/qmllanguage/data/lib/com/nokia/installedtest/PrivateType.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/qmldir (renamed from tests/auto/declarative/qmllanguage/data/lib/com/nokia/installedtest/qmldir)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/listAssignment.2.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/listAssignment.2.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/listAssignment.2.qml (renamed from tests/auto/declarative/qmllanguage/data/listAssignment.2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/listAssignment.3.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/listAssignment.3.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/listAssignment.3.qml (renamed from tests/auto/declarative/qmllanguage/data/listAssignment.3.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/listItemDeleteSelf.qml (renamed from tests/auto/declarative/qmllanguage/data/listItemDeleteSelf.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/listProperties.qml (renamed from tests/auto/declarative/qmllanguage/data/listProperties.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/missingObject.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/missingObject.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/missingObject.qml (renamed from tests/auto/declarative/qmllanguage/data/missingObject.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/missingSignal.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/missingSignal.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/missingSignal.qml (renamed from tests/auto/declarative/qmllanguage/data/missingSignal.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/missingValueTypeProperty.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/missingValueTypeProperty.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/missingValueTypeProperty.qml (renamed from tests/auto/declarative/qmllanguage/data/missingValueTypeProperty.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/nestedErrors.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/nestedErrors.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/nestedErrors.qml (renamed from tests/auto/declarative/qmllanguage/data/nestedErrors.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.1.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/nonexistantProperty.1.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.1.qml (renamed from tests/auto/declarative/qmllanguage/data/nonexistantProperty.1.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.2.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/nonexistantProperty.2.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.2.qml (renamed from tests/auto/declarative/qmllanguage/data/nonexistantProperty.2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.3.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/nonexistantProperty.3.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.3.qml (renamed from tests/auto/declarative/qmllanguage/data/nonexistantProperty.3.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.4.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/nonexistantProperty.4.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.4.qml (renamed from tests/auto/declarative/qmllanguage/data/nonexistantProperty.4.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.5.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/nonexistantProperty.5.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.5.qml (renamed from tests/auto/declarative/qmllanguage/data/nonexistantProperty.5.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.6.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/nonexistantProperty.6.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.6.qml (renamed from tests/auto/declarative/qmllanguage/data/nonexistantProperty.6.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/nullDotProperty.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/nullDotProperty.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/nullDotProperty.qml (renamed from tests/auto/declarative/qmllanguage/data/nullDotProperty.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/objectValueTypeProperty.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/objectValueTypeProperty.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/objectValueTypeProperty.qml (renamed from tests/auto/declarative/qmllanguage/data/objectValueTypeProperty.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/onCompleted.qml (renamed from tests/auto/declarative/qmllanguage/data/onCompleted.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/property.1.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/property.1.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/property.1.qml (renamed from tests/auto/declarative/qmllanguage/data/property.1.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/property.2.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/property.2.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/property.2.qml (renamed from tests/auto/declarative/qmllanguage/data/property.2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/property.3.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/property.3.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/property.3.qml (renamed from tests/auto/declarative/qmllanguage/data/property.3.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/property.4.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/property.4.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/property.4.qml (renamed from tests/auto/declarative/qmllanguage/data/property.4.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/property.5.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/property.5.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/property.5.qml (renamed from tests/auto/declarative/qmllanguage/data/property.5.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/propertyValueSource.2.qml (renamed from tests/auto/declarative/qmllanguage/data/propertyValueSource.2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/propertyValueSource.qml (renamed from tests/auto/declarative/qmllanguage/data/propertyValueSource.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/qmlAttachedPropertiesObjectMethod.1.qml (renamed from tests/auto/declarative/qmllanguage/data/qmlAttachedPropertiesObjectMethod.1.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/qmlAttachedPropertiesObjectMethod.2.qml (renamed from tests/auto/declarative/qmllanguage/data/qmlAttachedPropertiesObjectMethod.2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/readOnly.1.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/readOnly.1.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/readOnly.1.qml (renamed from tests/auto/declarative/qmllanguage/data/readOnly.1.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/readOnly.2.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/readOnly.2.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/readOnly.2.qml (renamed from tests/auto/declarative/qmllanguage/data/readOnly.2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/readOnly.3.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/readOnly.3.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/readOnly.3.qml (renamed from tests/auto/declarative/qmllanguage/data/readOnly.3.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/rootAsQmlComponent.qml (renamed from tests/auto/declarative/qmllanguage/data/rootAsQmlComponent.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/script.1.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/script.1.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/script.1.qml (renamed from tests/auto/declarative/qmllanguage/data/script.1.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/script.10.errors.txt1
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/script.10.qml (renamed from tests/auto/declarative/qmllanguage/data/script.10.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/script.11.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/script.11.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/script.11.qml (renamed from tests/auto/declarative/qmllanguage/data/script.11.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/script.12.errors.txt1
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/script.12.qml (renamed from tests/auto/declarative/qmllanguage/data/script.12.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/script.2.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/script.2.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/script.2.qml (renamed from tests/auto/declarative/qmllanguage/data/script.2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/script.3.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/script.3.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/script.3.qml (renamed from tests/auto/declarative/qmllanguage/data/script.3.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/script.4.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/script.4.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/script.4.qml (renamed from tests/auto/declarative/qmllanguage/data/script.4.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/script.5.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/script.5.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/script.5.qml (renamed from tests/auto/declarative/qmllanguage/data/script.5.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/script.6.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/script.6.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/script.6.qml (renamed from tests/auto/declarative/qmllanguage/data/script.6.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/script.7.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/script.7.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/script.7.qml (renamed from tests/auto/declarative/qmllanguage/data/script.7.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/script.8.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/script.8.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/script.8.qml (renamed from tests/auto/declarative/qmllanguage/data/script.8.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/script.9.errors.txt1
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/script.9.qml (renamed from tests/auto/declarative/qmllanguage/data/script.9.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/scriptString.qml (renamed from tests/auto/declarative/qmllanguage/data/scriptString.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/signal.1.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/signal.1.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/signal.1.qml (renamed from tests/auto/declarative/qmllanguage/data/signal.1.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/signal.2.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/signal.2.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/signal.2.qml (renamed from tests/auto/declarative/qmllanguage/data/signal.2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/signal.3.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/signal.3.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/signal.3.qml (renamed from tests/auto/declarative/qmllanguage/data/signal.3.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/simpleBindings.qml (renamed from tests/auto/declarative/qmllanguage/data/simpleBindings.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/simpleContainer.qml (renamed from tests/auto/declarative/qmllanguage/data/simpleContainer.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/simpleObject.qml (renamed from tests/auto/declarative/qmllanguage/data/simpleObject.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/subdir/Test.qml (renamed from tests/auto/declarative/qmllanguage/qtest/declarative/qmllanguage/Test.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/subdir/subsubdir/SubTest.qml (renamed from tests/auto/declarative/qmllanguage/data/subdir/subsubdir/SubTest.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/test.js (renamed from tests/auto/declarative/qmllanguage/data/test.js)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/test2.js (renamed from tests/auto/declarative/qmllanguage/data/test2.js)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/unregisteredObject.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/unregisteredObject.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/unregisteredObject.qml (renamed from tests/auto/declarative/qmllanguage/data/unregisteredObject.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/unsupportedProperty.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/unsupportedProperty.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/unsupportedProperty.qml (renamed from tests/auto/declarative/qmllanguage/data/unsupportedProperty.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/valueTypes.qml (renamed from tests/auto/declarative/qmllanguage/data/valueTypes.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/wrongType.1.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/wrongType.1.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/wrongType.1.qml (renamed from tests/auto/declarative/qmllanguage/data/wrongType.1.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/wrongType.10.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/wrongType.10.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/wrongType.10.qml (renamed from tests/auto/declarative/qmllanguage/data/wrongType.10.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/wrongType.11.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/wrongType.11.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/wrongType.11.qml (renamed from tests/auto/declarative/qmllanguage/data/wrongType.11.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/wrongType.12.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/wrongType.12.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/wrongType.12.qml (renamed from tests/auto/declarative/qmllanguage/data/wrongType.12.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/wrongType.13.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/wrongType.13.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/wrongType.13.qml (renamed from tests/auto/declarative/qmllanguage/data/wrongType.13.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/wrongType.14.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/wrongType.14.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/wrongType.14.qml (renamed from tests/auto/declarative/qmllanguage/data/wrongType.14.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/wrongType.15.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/wrongType.15.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/wrongType.15.qml (renamed from tests/auto/declarative/qmllanguage/data/wrongType.15.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/wrongType.2.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/wrongType.2.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/wrongType.2.qml (renamed from tests/auto/declarative/qmllanguage/data/wrongType.2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/wrongType.3.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/wrongType.3.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/wrongType.3.qml (renamed from tests/auto/declarative/qmllanguage/data/wrongType.3.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/wrongType.4.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/wrongType.4.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/wrongType.4.qml (renamed from tests/auto/declarative/qmllanguage/data/wrongType.4.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/wrongType.5.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/wrongType.5.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/wrongType.5.qml (renamed from tests/auto/declarative/qmllanguage/data/wrongType.5.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/wrongType.6.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/wrongType.6.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/wrongType.6.qml (renamed from tests/auto/declarative/qmllanguage/data/wrongType.6.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/wrongType.7.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/wrongType.7.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/wrongType.7.qml (renamed from tests/auto/declarative/qmllanguage/data/wrongType.7.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/wrongType.8.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/wrongType.8.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/wrongType.8.qml (renamed from tests/auto/declarative/qmllanguage/data/wrongType.8.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/wrongType.9.errors.txt (renamed from tests/auto/declarative/qmllanguage/data/wrongType.9.errors.txt)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/wrongType.9.qml (renamed from tests/auto/declarative/qmllanguage/data/wrongType.9.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/qdeclarativelanguage.pro14
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/LocalInternal.qml (renamed from tests/auto/declarative/qmllanguage/qtest/declarative/qmllanguage/LocalInternal.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/Test.qml (renamed from tests/auto/declarative/qmllanguage/data/subdir/Test.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/TestLocal.qml (renamed from tests/auto/declarative/qmllanguage/qtest/declarative/qmllanguage/TestLocal.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/TestSubDir.qml (renamed from tests/auto/declarative/qmllanguage/qtest/declarative/qmllanguage/TestSubDir.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/pics/blue.png (renamed from tests/auto/declarative/qmllanguage/qtest/declarative/qmllanguage/pics/blue.png)bin84 -> 84 bytes
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/qmldir (renamed from tests/auto/declarative/qmllanguage/qtest/declarative/qmllanguage/qmldir)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/subdir/SubTest.qml (renamed from tests/auto/declarative/qmllanguage/qtest/declarative/qmllanguage/subdir/SubTest.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/subdir/qmldir (renamed from tests/auto/declarative/qmllanguage/qtest/declarative/qmllanguage/subdir/qmldir)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/testtypes.cpp62
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/testtypes.h554
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp1406
-rw-r--r--tests/auto/declarative/qdeclarativelistmodel/qdeclarativelistmodel.pro6
-rw-r--r--tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp346
-rw-r--r--tests/auto/declarative/qdeclarativelistreference/data/MyType.qml (renamed from tests/auto/declarative/qmllist/data/MyType.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelistreference/data/engineTypes.qml (renamed from tests/auto/declarative/qmllist/data/engineTypes.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelistreference/data/variantToList.qml (renamed from tests/auto/declarative/qmllist/data/variantToList.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelistreference/qdeclarativelistreference.pro5
-rw-r--r--tests/auto/declarative/qdeclarativelistreference/tst_qdeclarativelistreference.cpp580
-rw-r--r--tests/auto/declarative/qdeclarativelistview/data/displaylist.qml43
-rw-r--r--tests/auto/declarative/qdeclarativelistview/data/itemlist.qml (renamed from tests/auto/declarative/qmlgraphicslistview/data/itemlist.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelistview/data/listview-enforcerange.qml (renamed from tests/auto/declarative/qmlgraphicslistview/data/listview-enforcerange.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelistview/data/listview-initCurrent.qml (renamed from tests/auto/declarative/qmlgraphicslistview/data/listview-initCurrent.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelistview/data/listview-sections.qml (renamed from tests/auto/declarative/qmlgraphicslistview/data/listview-sections.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelistview/data/listview.qml119
-rw-r--r--tests/auto/declarative/qdeclarativelistview/qdeclarativelistview.pro8
-rw-r--r--tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp1413
-rw-r--r--tests/auto/declarative/qdeclarativeloader/data/GraphicsWidget250x250.qml6
-rw-r--r--tests/auto/declarative/qdeclarativeloader/data/NoResize.qml (renamed from tests/auto/declarative/qmlgraphicsloader/data/NoResize.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeloader/data/NoResizeGraphicsWidget.qml (renamed from tests/auto/declarative/qmlgraphicsloader/data/NoResizeGraphicsWidget.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeloader/data/Rect120x60.qml (renamed from tests/auto/declarative/qmlgraphicsloader/data/Rect120x60.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeloader/data/SetSourceComponent.qml (renamed from tests/auto/declarative/qmlgraphicsloader/data/SetSourceComponent.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeloader/data/SizeGraphicsWidgetToLoader.qml (renamed from tests/auto/declarative/qmlgraphicsloader/data/SizeGraphicsWidgetToLoader.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeloader/data/SizeLoaderToGraphicsWidget.qml (renamed from tests/auto/declarative/qmlgraphicsloader/data/SizeLoaderToGraphicsWidget.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeloader/data/SizeToItem.qml (renamed from tests/auto/declarative/qmlgraphicsloader/data/SizeToItem.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeloader/data/SizeToLoader.qml (renamed from tests/auto/declarative/qmlgraphicsloader/data/SizeToLoader.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeloader/qdeclarativeloader.pro11
-rw-r--r--tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp464
-rw-r--r--tests/auto/declarative/qdeclarativemetatype/qdeclarativemetatype.pro6
-rw-r--r--tests/auto/declarative/qdeclarativemetatype/tst_qdeclarativemetatype.cpp378
-rw-r--r--tests/auto/declarative/qdeclarativemoduleplugin/com/nokia/AutoTestQmlPluginType/qmldir1
-rw-r--r--tests/auto/declarative/qdeclarativemoduleplugin/plugin.qml (renamed from tests/auto/declarative/qmlmoduleplugin/plugin.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativemoduleplugin/plugin/plugin.cpp85
-rw-r--r--tests/auto/declarative/qdeclarativemoduleplugin/plugin/plugin.pro6
-rw-r--r--tests/auto/declarative/qdeclarativemoduleplugin/qdeclarativemoduleplugin.pro7
-rw-r--r--tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp117
-rw-r--r--tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.pro5
-rw-r--r--tests/auto/declarative/qdeclarativemousearea/data/dragproperties.qml (renamed from tests/auto/declarative/qmlgraphicsmousearea/data/dragproperties.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativemousearea/qdeclarativemousearea.pro9
-rw-r--r--tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp138
-rw-r--r--tests/auto/declarative/qdeclarativenumberformatter/qdeclarativenumberformatter.pro5
-rw-r--r--tests/auto/declarative/qdeclarativenumberformatter/tst_qdeclarativenumberformatter.cpp222
-rw-r--r--tests/auto/declarative/qdeclarativeparticles/data/particle.png (renamed from tests/auto/declarative/qmlgraphicsparticles/data/particle.png)bin262 -> 262 bytes
-rw-r--r--tests/auto/declarative/qdeclarativeparticles/data/particlemotion.qml33
-rw-r--r--tests/auto/declarative/qdeclarativeparticles/data/particles.qml (renamed from tests/auto/declarative/qmlgraphicsparticles/data/particles.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeparticles/qdeclarativeparticles.pro8
-rw-r--r--tests/auto/declarative/qdeclarativeparticles/tst_qdeclarativeparticles.cpp209
-rw-r--r--tests/auto/declarative/qdeclarativepathview/data/datamodel.qml (renamed from tests/auto/declarative/qmlgraphicspathview/data/datamodel.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativepathview/data/displaypath.qml60
-rw-r--r--tests/auto/declarative/qdeclarativepathview/data/path.qml (renamed from tests/auto/declarative/qmlgraphicspathview/data/path.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativepathview/data/pathview.qml (renamed from tests/auto/declarative/qmlgraphicspathview/data/pathview.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativepathview/data/pathview1.qml (renamed from tests/auto/declarative/qmlgraphicspathview/data/pathview1.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativepathview/data/pathview2.qml (renamed from tests/auto/declarative/qmlgraphicspathview/data/pathview2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativepathview/data/pathview3.qml (renamed from tests/auto/declarative/qmlgraphicspathview/data/pathview3.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativepathview/qdeclarativepathview.pro8
-rw-r--r--tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp529
-rw-r--r--tests/auto/declarative/qdeclarativepixmapcache/data/exists.png (renamed from tests/auto/declarative/qmlimageprovider/data/exists.png)bin2738 -> 2738 bytes
-rw-r--r--tests/auto/declarative/qdeclarativepixmapcache/data/exists1.png (renamed from tests/auto/declarative/qmlimageprovider/data/exists1.png)bin2738 -> 2738 bytes
-rw-r--r--tests/auto/declarative/qdeclarativepixmapcache/data/exists2.png (renamed from tests/auto/declarative/qmlimageprovider/data/exists2.png)bin2738 -> 2738 bytes
-rw-r--r--tests/auto/declarative/qdeclarativepixmapcache/qdeclarativepixmapcache.pro9
-rw-r--r--tests/auto/declarative/qdeclarativepixmapcache/tst_qdeclarativepixmapcache.cpp282
-rw-r--r--tests/auto/declarative/qdeclarativepositioners/data/grid-animated.qml (renamed from tests/auto/declarative/qmlgraphicspositioners/data/grid-animated.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativepositioners/data/grid-spacing.qml (renamed from tests/auto/declarative/qmlgraphicspositioners/data/grid-spacing.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativepositioners/data/grid.qml (renamed from tests/auto/declarative/qmlgraphicspositioners/data/grid.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativepositioners/data/horizontal-animated.qml (renamed from tests/auto/declarative/qmlgraphicspositioners/data/horizontal-animated.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativepositioners/data/horizontal-spacing.qml (renamed from tests/auto/declarative/qmlgraphicspositioners/data/horizontal-spacing.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativepositioners/data/horizontal.qml (renamed from tests/auto/declarative/qmlgraphicspositioners/data/horizontal.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativepositioners/data/propertychanges.qml39
-rw-r--r--tests/auto/declarative/qdeclarativepositioners/data/repeater.qml (renamed from tests/auto/declarative/qmlgraphicspositioners/data/repeater.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativepositioners/data/vertical-animated.qml (renamed from tests/auto/declarative/qmlgraphicspositioners/data/vertical-animated.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativepositioners/data/vertical-spacing.qml (renamed from tests/auto/declarative/qmlgraphicspositioners/data/vertical-spacing.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativepositioners/data/vertical.qml (renamed from tests/auto/declarative/qmlgraphicspositioners/data/vertical.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativepositioners/qdeclarativepositioners.pro7
-rw-r--r--tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp455
-rw-r--r--tests/auto/declarative/qdeclarativeproperty/qdeclarativeproperty.pro5
-rw-r--r--tests/auto/declarative/qdeclarativeproperty/tst_qdeclarativeproperty.cpp1322
-rw-r--r--tests/auto/declarative/qdeclarativepropertymap/qdeclarativepropertymap.pro5
-rw-r--r--tests/auto/declarative/qdeclarativepropertymap/tst_qdeclarativepropertymap.cpp171
-rw-r--r--tests/auto/declarative/qdeclarativeqt/data/closestangle.qml (renamed from tests/auto/declarative/qmlqt/data/closestangle.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeqt/data/consoleLog.qml (renamed from tests/auto/declarative/qmlqt/data/consoleLog.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeqt/data/createComponent.qml (renamed from tests/auto/declarative/qmlqt/data/createComponent.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeqt/data/createComponentData.qml (renamed from tests/auto/declarative/qmlqt/data/createComponentData.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeqt/data/createQmlObject.qml (renamed from tests/auto/declarative/qmlqt/data/createQmlObject.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeqt/data/darker.qml (renamed from tests/auto/declarative/qmlqt/data/darker.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeqt/data/enums.qml (renamed from tests/auto/declarative/qmlqt/data/enums.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeqt/data/hsla.qml (renamed from tests/auto/declarative/qmlqt/data/hsla.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeqt/data/lighter.qml (renamed from tests/auto/declarative/qmlqt/data/lighter.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeqt/data/md5.qml (renamed from tests/auto/declarative/qmlqt/data/md5.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeqt/data/point.qml (renamed from tests/auto/declarative/qmlqt/data/point.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeqt/data/rect.qml (renamed from tests/auto/declarative/qmlqt/data/rect.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeqt/data/rgba.qml (renamed from tests/auto/declarative/qmlqt/data/rgba.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeqt/data/size.qml (renamed from tests/auto/declarative/qmlqt/data/size.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeqt/data/tint.qml (renamed from tests/auto/declarative/qmlqt/data/tint.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeqt/data/vector.qml (renamed from tests/auto/declarative/qmlqt/data/vector.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativeqt/qdeclarativeqt.pro9
-rw-r--r--tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp369
-rw-r--r--tests/auto/declarative/qdeclarativerepeater/data/intmodel.qml (renamed from tests/auto/declarative/qmlgraphicsrepeater/data/intmodel.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativerepeater/data/itemlist.qml (renamed from tests/auto/declarative/qmlgraphicsrepeater/data/itemlist.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativerepeater/data/objlist.qml (renamed from tests/auto/declarative/qmlgraphicsrepeater/data/objlist.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativerepeater/data/properties.qml (renamed from tests/auto/declarative/qmlgraphicsrepeater/data/properties.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativerepeater/data/repeater.qml (renamed from tests/auto/declarative/qmlgraphicsrepeater/data/repeater.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativerepeater/data/repeater2.qml (renamed from tests/auto/declarative/qmlgraphicsrepeater/data/repeater2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativerepeater/qdeclarativerepeater.pro8
-rw-r--r--tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp385
-rw-r--r--tests/auto/declarative/qdeclarativespringfollow/data/springfollow1.qml (renamed from tests/auto/declarative/qmlspringfollow/data/springfollow1.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativespringfollow/data/springfollow2.qml (renamed from tests/auto/declarative/qmlspringfollow/data/springfollow2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativespringfollow/data/springfollow3.qml (renamed from tests/auto/declarative/qmlspringfollow/data/springfollow3.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativespringfollow/qdeclarativespringfollow.pro8
-rw-r--r--tests/auto/declarative/qdeclarativespringfollow/tst_qdeclarativespringfollow.cpp137
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/ExtendedRectangle.qml (renamed from tests/auto/declarative/qmlstates/data/ExtendedRectangle.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/anchorChanges.qml (renamed from tests/auto/declarative/qmlstates/data/anchorChanges.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/anchorChanges2.qml (renamed from tests/auto/declarative/qmlstates/data/anchorChanges2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/anchorChanges3.qml (renamed from tests/auto/declarative/qmlstates/data/anchorChanges3.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/anchorChanges4.qml (renamed from tests/auto/declarative/qmlstates/data/anchorChanges4.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/anchorChanges5.qml (renamed from tests/auto/declarative/qmlstates/data/anchorChanges5.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/autoStateAtStartupRestoreBug.qml (renamed from tests/auto/declarative/qmlstates/data/autoStateAtStartupRestoreBug.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/basicBinding.qml (renamed from tests/auto/declarative/qmlstates/data/basicBinding.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/basicBinding2.qml (renamed from tests/auto/declarative/qmlstates/data/basicBinding2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/basicBinding3.qml (renamed from tests/auto/declarative/qmlstates/data/basicBinding3.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/basicBinding4.qml (renamed from tests/auto/declarative/qmlstates/data/basicBinding4.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/basicChanges.qml (renamed from tests/auto/declarative/qmlstates/data/basicChanges.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/basicChanges2.qml (renamed from tests/auto/declarative/qmlstates/data/basicChanges2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/basicChanges3.qml (renamed from tests/auto/declarative/qmlstates/data/basicChanges3.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/basicChanges4.qml19
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/basicExtension.qml (renamed from tests/auto/declarative/qmlstates/data/basicExtension.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/deleting.qml (renamed from tests/auto/declarative/qmlstates/data/deleting.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/deletingState.qml (renamed from tests/auto/declarative/qmlstates/data/deletingState.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/explicit.qml (renamed from tests/auto/declarative/qmlstates/data/explicit.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/fakeExtension.qml (renamed from tests/auto/declarative/qmlstates/data/fakeExtension.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/illegalTempState.qml (renamed from tests/auto/declarative/qmlstates/data/illegalTempState.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/legalTempState.qml (renamed from tests/auto/declarative/qmlstates/data/legalTempState.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/nonExistantProp.qml (renamed from tests/auto/declarative/qmlstates/data/nonExistantProp.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/parentChange.qml (renamed from tests/auto/declarative/qmlstates/data/parentChange.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/parentChange2.qml (renamed from tests/auto/declarative/qmlstates/data/parentChange2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/parentChange3.qml (renamed from tests/auto/declarative/qmlstates/data/parentChange3.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/parentChange4.qml (renamed from tests/auto/declarative/qmlstates/data/parentChange4.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/parentChange5.qml (renamed from tests/auto/declarative/qmlstates/data/parentChange5.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/propertyErrors.qml (renamed from tests/auto/declarative/qmlstates/data/propertyErrors.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/reset.qml20
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/restoreEntryValues.qml (renamed from tests/auto/declarative/qmlstates/data/restoreEntryValues.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/script.qml (renamed from tests/auto/declarative/qmlstates/data/script.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/signalOverride.qml (renamed from tests/auto/declarative/qmlstates/data/signalOverride.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/signalOverride2.qml (renamed from tests/auto/declarative/qmlstates/data/signalOverride2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/signalOverrideCrash.qml (renamed from tests/auto/declarative/qmlstates/data/signalOverrideCrash.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativestates/qdeclarativestates.pro8
-rw-r--r--tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp969
-rw-r--r--tests/auto/declarative/qdeclarativestyledtext/qdeclarativestyledtext.pro9
-rw-r--r--tests/auto/declarative/qdeclarativestyledtext/tst_qdeclarativestyledtext.cpp96
-rw-r--r--tests/auto/declarative/qdeclarativesystempalette/qdeclarativesystempalette.pro5
-rw-r--r--tests/auto/declarative/qdeclarativesystempalette/tst_qdeclarativesystempalette.cpp187
-rw-r--r--tests/auto/declarative/qdeclarativetext/qdeclarativetext.pro5
-rw-r--r--tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp844
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/data/cursorTest.qml (renamed from tests/auto/declarative/qmlgraphicstextedit/data/cursorTest.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/data/http/ErrItem.qml (renamed from tests/auto/declarative/qmlgraphicstextedit/data/http/ErrItem.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/data/http/NormItem.qml (renamed from tests/auto/declarative/qmlgraphicstextedit/data/http/NormItem.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/data/http/cursorHttpTest.qml (renamed from tests/auto/declarative/qmlgraphicstextedit/data/http/cursorHttpTest.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/data/http/cursorHttpTestFail1.qml (renamed from tests/auto/declarative/qmlgraphicstextedit/data/http/cursorHttpTestFail1.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/data/http/cursorHttpTestFail2.qml (renamed from tests/auto/declarative/qmlgraphicstextedit/data/http/cursorHttpTestFail2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/data/http/cursorHttpTestPass.qml (renamed from tests/auto/declarative/qmlgraphicstextedit/data/http/cursorHttpTestPass.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/data/httpfail/FailItem.qml (renamed from tests/auto/declarative/qmlgraphicstextedit/data/httpfail/FailItem.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/data/httpslow/WaitItem.qml (renamed from tests/auto/declarative/qmlgraphicstextedit/data/httpslow/WaitItem.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/data/inputmethodhints.qml (renamed from tests/auto/declarative/qmlgraphicstextedit/data/inputmethodhints.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/data/navigation.qml (renamed from tests/auto/declarative/qmlgraphicstextedit/data/navigation.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/data/readOnly.qml (renamed from tests/auto/declarative/qmlgraphicstextedit/data/readOnly.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/qdeclarativetextedit.pro9
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp791
-rw-r--r--tests/auto/declarative/qdeclarativetextinput/data/cursorTest.qml (renamed from tests/auto/declarative/qmlgraphicstextinput/data/cursorTest.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativetextinput/data/inputmethodhints.qml (renamed from tests/auto/declarative/qmlgraphicstextinput/data/inputmethodhints.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativetextinput/data/masks.qml (renamed from tests/auto/declarative/qmlgraphicstextinput/data/masks.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativetextinput/data/maxLength.qml (renamed from tests/auto/declarative/qmlgraphicstextinput/data/maxLength.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativetextinput/data/navigation.qml (renamed from tests/auto/declarative/qmlgraphicstextinput/data/navigation.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativetextinput/data/readOnly.qml (renamed from tests/auto/declarative/qmlgraphicstextinput/data/readOnly.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativetextinput/data/validators.qml (renamed from tests/auto/declarative/qmlgraphicstextinput/data/validators.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativetextinput/qdeclarativetextinput.pro8
-rw-r--r--tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp656
-rw-r--r--tests/auto/declarative/qdeclarativetimer/qdeclarativetimer.pro7
-rw-r--r--tests/auto/declarative/qdeclarativetimer/tst_qdeclarativetimer.cpp285
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/autoBindingRemoval.2.qml (renamed from tests/auto/declarative/qmlvaluetypes/data/autoBindingRemoval.2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/autoBindingRemoval.3.qml (renamed from tests/auto/declarative/qmlvaluetypes/data/autoBindingRemoval.3.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/autoBindingRemoval.qml (renamed from tests/auto/declarative/qmlvaluetypes/data/autoBindingRemoval.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/bindingAssignment.qml (renamed from tests/auto/declarative/qmlvaluetypes/data/bindingAssignment.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/bindingConflict.qml (renamed from tests/auto/declarative/qmlvaluetypes/data/bindingConflict.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/bindingRead.qml (renamed from tests/auto/declarative/qmlvaluetypes/data/bindingRead.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/bindingVariantCopy.qml (renamed from tests/auto/declarative/qmlvaluetypes/data/bindingVariantCopy.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/deletedObject.js (renamed from tests/auto/declarative/qmlvaluetypes/data/deletedObject.js)0
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/deletedObject.qml (renamed from tests/auto/declarative/qmlvaluetypes/data/deletedObject.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/enums.1.qml6
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/enums.2.qml6
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/font_read.qml (renamed from tests/auto/declarative/qmlvaluetypes/data/font_read.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/font_write.2.qml (renamed from tests/auto/declarative/qmlvaluetypes/data/font_write.2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/font_write.3.qml (renamed from tests/auto/declarative/qmlvaluetypes/data/font_write.3.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/font_write.qml (renamed from tests/auto/declarative/qmlvaluetypes/data/font_write.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/point_read.qml (renamed from tests/auto/declarative/qmlvaluetypes/data/point_read.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/point_write.qml (renamed from tests/auto/declarative/qmlvaluetypes/data/point_write.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/pointf_read.qml (renamed from tests/auto/declarative/qmlvaluetypes/data/pointf_read.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/pointf_write.qml (renamed from tests/auto/declarative/qmlvaluetypes/data/pointf_write.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/rect_read.qml (renamed from tests/auto/declarative/qmlvaluetypes/data/rect_read.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/rect_write.qml (renamed from tests/auto/declarative/qmlvaluetypes/data/rect_write.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/rectf_read.qml (renamed from tests/auto/declarative/qmlvaluetypes/data/rectf_read.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/rectf_write.qml (renamed from tests/auto/declarative/qmlvaluetypes/data/rectf_write.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/scriptAccess.qml (renamed from tests/auto/declarative/qmlvaluetypes/data/scriptAccess.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/scriptVariantCopy.qml (renamed from tests/auto/declarative/qmlvaluetypes/data/scriptVariantCopy.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/size_read.qml (renamed from tests/auto/declarative/qmlvaluetypes/data/size_read.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/size_write.qml (renamed from tests/auto/declarative/qmlvaluetypes/data/size_write.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/sizef_read.qml (renamed from tests/auto/declarative/qmlvaluetypes/data/sizef_read.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/sizef_write.qml (renamed from tests/auto/declarative/qmlvaluetypes/data/sizef_write.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/staticAssignment.qml (renamed from tests/auto/declarative/qmlvaluetypes/data/staticAssignment.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/valueInterceptors.qml (renamed from tests/auto/declarative/qmlvaluetypes/data/valueInterceptors.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/valueSources.qml (renamed from tests/auto/declarative/qmlvaluetypes/data/valueSources.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/vector3d_read.qml (renamed from tests/auto/declarative/qmlvaluetypes/data/vector3d_read.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/vector3d_write.qml (renamed from tests/auto/declarative/qmlvaluetypes/data/vector3d_write.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/qdeclarativevaluetypes.pro10
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/testtypes.cpp48
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/testtypes.h156
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp616
-rw-r--r--tests/auto/declarative/qdeclarativewebview/data/basic.html (renamed from tests/auto/declarative/qmlgraphicswebview/data/basic.html)0
-rw-r--r--tests/auto/declarative/qdeclarativewebview/data/basic.ico (renamed from tests/auto/declarative/qmlgraphicswebview/data/basic.ico)bin318 -> 318 bytes
-rw-r--r--tests/auto/declarative/qdeclarativewebview/data/basic.png (renamed from tests/auto/declarative/qmlgraphicswebview/data/basic.png)bin3961 -> 3961 bytes
-rw-r--r--tests/auto/declarative/qdeclarativewebview/data/basic.qml (renamed from tests/auto/declarative/qmlgraphicswebview/data/basic.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativewebview/data/elements.html (renamed from tests/auto/declarative/qmlgraphicswebview/data/elements.html)0
-rw-r--r--tests/auto/declarative/qdeclarativewebview/data/elements.qml (renamed from tests/auto/declarative/qmlgraphicswebview/data/elements.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativewebview/data/forward.html12
-rw-r--r--tests/auto/declarative/qdeclarativewebview/data/javaScript.html (renamed from tests/auto/declarative/qmlgraphicswebview/data/javaScript.html)0
-rw-r--r--tests/auto/declarative/qdeclarativewebview/data/javaScript.qml (renamed from tests/auto/declarative/qmlgraphicswebview/data/javaScript.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativewebview/data/loadError.qml (renamed from tests/auto/declarative/qmlgraphicswebview/data/loadError.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativewebview/data/newwindows.html (renamed from tests/auto/declarative/qmlgraphicswebview/data/newwindows.html)0
-rw-r--r--tests/auto/declarative/qdeclarativewebview/data/newwindows.qml (renamed from tests/auto/declarative/qmlgraphicswebview/data/newwindows.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativewebview/data/pixelCache.html (renamed from tests/auto/declarative/qmlgraphicswebview/data/pixelCache.html)0
-rw-r--r--tests/auto/declarative/qdeclarativewebview/data/pixelCache.qml (renamed from tests/auto/declarative/qmlgraphicswebview/data/pixelCache.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativewebview/data/propertychanges.qml33
-rw-r--r--tests/auto/declarative/qdeclarativewebview/data/sethtml.qml (renamed from tests/auto/declarative/qmlgraphicswebview/data/sethtml.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativewebview/qdeclarativewebview.pro10
-rw-r--r--tests/auto/declarative/qdeclarativewebview/testtypes.cpp52
-rw-r--r--tests/auto/declarative/qdeclarativewebview/testtypes.h66
-rw-r--r--tests/auto/declarative/qdeclarativewebview/tst_qdeclarativewebview.cpp513
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/abort.expect (renamed from tests/auto/declarative/qmlxmlhttprequest/data/abort.expect)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/abort.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/abort.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/abort.reply (renamed from tests/auto/declarative/qmlxmlhttprequest/data/abort.reply)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/abort_opened.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/abort_opened.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/abort_unsent.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/abort_unsent.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/attr.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/attr.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/attr.xml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/attr.xml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/callbackException.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/callbackException.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/cdata.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/cdata.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/cdata.xml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/cdata.xml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/constructor.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/constructor.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/defaultState.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/defaultState.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/document.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/document.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/document.xml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/document.xml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/domExceptionCodes.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/domExceptionCodes.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/element.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/element.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/element.xml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/element.xml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/getAllResponseHeaders.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders_args.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/getAllResponseHeaders_args.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders_sent.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/getAllResponseHeaders_sent.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders_unsent.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/getAllResponseHeaders_unsent.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader.expect (renamed from tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader.expect)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader.reply (renamed from tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader.reply)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader_args.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader_args.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader_sent.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader_sent.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader_unsent.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader_unsent.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/instanceStateValues.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/instanceStateValues.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/invalidMethodUsage.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/invalidMethodUsage.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/open.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/open.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/open_arg_count.1.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/open_arg_count.1.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/open_arg_count.2.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/open_arg_count.2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/open_invalid_method.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/open_invalid_method.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/open_network.expect (renamed from tests/auto/declarative/qmlxmlhttprequest/data/open_network.expect)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/open_network.reply (renamed from tests/auto/declarative/qmlxmlhttprequest/data/open_network.reply)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/open_network.wait (renamed from tests/auto/declarative/qmlxmlhttprequest/data/open_network.wait)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/open_sync.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/open_sync.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/open_user.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/open_user.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/open_username.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/open_username.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/redirectError.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/redirectError.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/redirectRecur.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/redirectRecur.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/redirects.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/redirects.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/redirecttarget.html (renamed from tests/auto/declarative/qmlxmlhttprequest/data/redirecttarget.html)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/responseText.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/responseText.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/responseXML_invalid.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/responseXML_invalid.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/seconddocument.html (renamed from tests/auto/declarative/qmlxmlhttprequest/data/seconddocument.html)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/send_alreadySent.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/send_alreadySent.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.1.expect (renamed from tests/auto/declarative/qmlxmlhttprequest/data/send_data.1.expect)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.1.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/send_data.1.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.2.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/send_data.2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.3.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/send_data.3.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.4.expect (renamed from tests/auto/declarative/qmlxmlhttprequest/data/send_data.4.expect)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.4.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/send_data.4.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.5.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/send_data.5.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.6.expect (renamed from tests/auto/declarative/qmlxmlhttprequest/data/send_data.6.expect)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.6.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/send_data.6.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.7.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/send_data.7.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.reply (renamed from tests/auto/declarative/qmlxmlhttprequest/data/send_data.reply)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/send_ignoreData.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData.reply (renamed from tests/auto/declarative/qmlxmlhttprequest/data/send_ignoreData.reply)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData_GET.expect (renamed from tests/auto/declarative/qmlxmlhttprequest/data/send_ignoreData_GET.expect)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData_PUT.expect (renamed from tests/auto/declarative/qmlxmlhttprequest/data/send_ignoreData_PUT.expect)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/send_unsent.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/send_unsent.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader.expect (renamed from tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader.expect)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader.reply (renamed from tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader.reply)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_args.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader_args.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_illegalName.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader_illegalName.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_sent.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader_sent.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_unsent.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader_unsent.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/staticStateValues.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/staticStateValues.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/status.200.reply (renamed from tests/auto/declarative/qmlxmlhttprequest/data/status.200.reply)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/status.404.reply (renamed from tests/auto/declarative/qmlxmlhttprequest/data/status.404.reply)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/status.expect (renamed from tests/auto/declarative/qmlxmlhttprequest/data/status.expect)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/status.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/status.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/statusText.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/statusText.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/testdocument.html (renamed from tests/auto/declarative/qmlxmlhttprequest/data/testdocument.html)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/text.qml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/text.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/text.xml (renamed from tests/auto/declarative/qmlxmlhttprequest/data/text.xml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/qdeclarativexmlhttprequest.pro13
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/tst_qdeclarativexmlhttprequest.cpp1315
-rw-r--r--tests/auto/declarative/qdeclarativexmllistmodel/data/model.qml (renamed from tests/auto/declarative/qmlxmllistmodel/data/model.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmllistmodel/data/model.xml (renamed from tests/auto/declarative/qmlxmllistmodel/data/model.xml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmllistmodel/data/model2.qml (renamed from tests/auto/declarative/qmlxmllistmodel/data/model2.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmllistmodel/data/recipes.qml (renamed from tests/auto/declarative/qmlxmllistmodel/data/recipes.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmllistmodel/data/recipes.xml (renamed from tests/auto/declarative/qmlxmllistmodel/data/recipes.xml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmllistmodel/data/roleErrors.qml (renamed from tests/auto/declarative/qmlxmllistmodel/data/roleErrors.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmllistmodel/data/roleKeys.qml13
-rw-r--r--tests/auto/declarative/qdeclarativexmllistmodel/data/unique.qml (renamed from tests/auto/declarative/qmlxmllistmodel/data/unique.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativexmllistmodel/qdeclarativexmllistmodel.pro11
-rw-r--r--tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp457
-rw-r--r--tests/auto/declarative/qmlanimations/qmlanimations.pro6
-rw-r--r--tests/auto/declarative/qmlanimations/tst_qmlanimations.cpp672
-rw-r--r--tests/auto/declarative/qmlbehaviors/qmlbehaviors.pro6
-rw-r--r--tests/auto/declarative/qmlbehaviors/tst_qmlbehaviors.cpp301
-rw-r--r--tests/auto/declarative/qmlbinding/qmlbinding.pro8
-rw-r--r--tests/auto/declarative/qmlbinding/tst_qmlbinding.cpp107
-rw-r--r--tests/auto/declarative/qmlconnection/data/test-connection.qml10
-rw-r--r--tests/auto/declarative/qmlconnection/data/test-connection2.qml3
-rw-r--r--tests/auto/declarative/qmlconnection/data/test-connection3.qml3
-rw-r--r--tests/auto/declarative/qmlconnection/data/trimming.qml10
-rw-r--r--tests/auto/declarative/qmlconnection/qmlconnection.pro8
-rw-r--r--tests/auto/declarative/qmlconnection/tst_qmlconnection.cpp139
-rw-r--r--tests/auto/declarative/qmlcontext/qmlcontext.pro6
-rw-r--r--tests/auto/declarative/qmlcontext/tst_qmlcontext.cpp434
-rw-r--r--tests/auto/declarative/qmldatetimeformatter/qmldatetimeformatter.pro5
-rw-r--r--tests/auto/declarative/qmldatetimeformatter/tst_qmldatetimeformatter.cpp150
-rw-r--r--tests/auto/declarative/qmldebug/qmldebug.pro7
-rw-r--r--tests/auto/declarative/qmldebug/tst_qmldebug.cpp841
-rw-r--r--tests/auto/declarative/qmldebugclient/qmldebugclient.pro7
-rw-r--r--tests/auto/declarative/qmldebugclient/tst_qmldebugclient.cpp157
-rw-r--r--tests/auto/declarative/qmldebugservice/qmldebugservice.pro7
-rw-r--r--tests/auto/declarative/qmldebugservice/tst_qmldebugservice.cpp190
-rw-r--r--tests/auto/declarative/qmldom/qmldom.pro7
-rw-r--r--tests/auto/declarative/qmldom/tst_qmldom.cpp1313
-rw-r--r--tests/auto/declarative/qmleasefollow/qmleasefollow.pro8
-rw-r--r--tests/auto/declarative/qmleasefollow/tst_qmleasefollow.cpp122
-rw-r--r--tests/auto/declarative/qmlecmascript/qmlecmascript.pro10
-rw-r--r--tests/auto/declarative/qmlecmascript/testtypes.cpp82
-rw-r--r--tests/auto/declarative/qmlecmascript/testtypes.h592
-rw-r--r--tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp1659
-rw-r--r--tests/auto/declarative/qmlengine/qmlengine.pro8
-rw-r--r--tests/auto/declarative/qmlengine/tst_qmlengine.cpp240
-rw-r--r--tests/auto/declarative/qmlerror/qmlerror.pro6
-rw-r--r--tests/auto/declarative/qmlerror/tst_qmlerror.cpp242
-rw-r--r--tests/auto/declarative/qmlfontloader/qmlfontloader.pro8
-rw-r--r--tests/auto/declarative/qmlfontloader/tst_qmlfontloader.cpp156
-rw-r--r--tests/auto/declarative/qmlgraphicsanchors/qmlgraphicsanchors.pro6
-rw-r--r--tests/auto/declarative/qmlgraphicsanchors/tst_qmlgraphicsanchors.cpp459
-rw-r--r--tests/auto/declarative/qmlgraphicsanimatedimage/qmlgraphicsanimatedimage.pro7
-rw-r--r--tests/auto/declarative/qmlgraphicsanimatedimage/tst_qmlgraphicsanimatedimage.cpp191
-rw-r--r--tests/auto/declarative/qmlgraphicsborderimage/qmlgraphicsborderimage.pro9
-rw-r--r--tests/auto/declarative/qmlgraphicsborderimage/tst_qmlgraphicsborderimage.cpp351
-rw-r--r--tests/auto/declarative/qmlgraphicsflickable/data/flickable02.qml14
-rw-r--r--tests/auto/declarative/qmlgraphicsflickable/data/flickable03.qml14
-rw-r--r--tests/auto/declarative/qmlgraphicsflickable/data/flickable04.qml16
-rw-r--r--tests/auto/declarative/qmlgraphicsflickable/qmlgraphicsflickable.pro8
-rw-r--r--tests/auto/declarative/qmlgraphicsflickable/tst_qmlgraphicsflickable.cpp224
-rw-r--r--tests/auto/declarative/qmlgraphicsflipable/qmlgraphicsflipable.pro8
-rw-r--r--tests/auto/declarative/qmlgraphicsflipable/tst_qmlgraphicsflipable.cpp113
-rw-r--r--tests/auto/declarative/qmlgraphicsgridview/qmlgraphicsgridview.pro8
-rw-r--r--tests/auto/declarative/qmlgraphicsgridview/tst_qmlgraphicsgridview.cpp967
-rw-r--r--tests/auto/declarative/qmlgraphicsimage/qmlgraphicsimage.pro9
-rw-r--r--tests/auto/declarative/qmlgraphicsimage/tst_qmlgraphicsimage.cpp247
-rw-r--r--tests/auto/declarative/qmlgraphicsitem/qmlgraphicsitem.pro7
-rw-r--r--tests/auto/declarative/qmlgraphicsitem/tst_qmlgraphicsitem.cpp321
-rw-r--r--tests/auto/declarative/qmlgraphicslistview/data/listview.qml119
-rw-r--r--tests/auto/declarative/qmlgraphicslistview/qmlgraphicslistview.pro8
-rw-r--r--tests/auto/declarative/qmlgraphicslistview/tst_qmlgraphicslistview.cpp1374
-rw-r--r--tests/auto/declarative/qmlgraphicsloader/data/GraphicsWidget250x250.qml5
-rw-r--r--tests/auto/declarative/qmlgraphicsloader/qmlgraphicsloader.pro11
-rw-r--r--tests/auto/declarative/qmlgraphicsloader/tst_qmlgraphicsloader.cpp464
-rw-r--r--tests/auto/declarative/qmlgraphicsmousearea/qmlgraphicsmousearea.pro9
-rw-r--r--tests/auto/declarative/qmlgraphicsmousearea/tst_qmlgraphicsmousearea.cpp139
-rw-r--r--tests/auto/declarative/qmlgraphicsparticles/qmlgraphicsparticles.pro8
-rw-r--r--tests/auto/declarative/qmlgraphicsparticles/tst_qmlgraphicsparticles.cpp122
-rw-r--r--tests/auto/declarative/qmlgraphicspathview/qmlgraphicspathview.pro8
-rw-r--r--tests/auto/declarative/qmlgraphicspathview/tst_qmlgraphicspathview.cpp491
-rw-r--r--tests/auto/declarative/qmlgraphicspositioners/qmlgraphicspositioners.pro7
-rw-r--r--tests/auto/declarative/qmlgraphicspositioners/tst_qmlgraphicspositioners.cpp417
-rw-r--r--tests/auto/declarative/qmlgraphicsrepeater/qmlgraphicsrepeater.pro8
-rw-r--r--tests/auto/declarative/qmlgraphicsrepeater/tst_qmlgraphicsrepeater.cpp387
-rw-r--r--tests/auto/declarative/qmlgraphicstext/qmlgraphicstext.pro5
-rw-r--r--tests/auto/declarative/qmlgraphicstext/tst_qmlgraphicstext.cpp844
-rw-r--r--tests/auto/declarative/qmlgraphicstextedit/qmlgraphicstextedit.pro9
-rw-r--r--tests/auto/declarative/qmlgraphicstextedit/tst_qmlgraphicstextedit.cpp798
-rw-r--r--tests/auto/declarative/qmlgraphicstextinput/qmlgraphicstextinput.pro8
-rw-r--r--tests/auto/declarative/qmlgraphicstextinput/tst_qmlgraphicstextinput.cpp663
-rw-r--r--tests/auto/declarative/qmlgraphicswebview/data/forward.html12
-rw-r--r--tests/auto/declarative/qmlgraphicswebview/qmlgraphicswebview.pro10
-rw-r--r--tests/auto/declarative/qmlgraphicswebview/testtypes.cpp49
-rw-r--r--tests/auto/declarative/qmlgraphicswebview/testtypes.h64
-rw-r--r--tests/auto/declarative/qmlgraphicswebview/tst_qmlgraphicswebview.cpp396
-rw-r--r--tests/auto/declarative/qmlimageprovider/qmlimageprovider.pro12
-rw-r--r--tests/auto/declarative/qmlimageprovider/tst_qmlimageprovider.cpp166
-rw-r--r--tests/auto/declarative/qmlinfo/qmlinfo.pro7
-rw-r--r--tests/auto/declarative/qmlinfo/tst_qmlinfo.cpp139
-rw-r--r--tests/auto/declarative/qmlinstruction/qmlinstruction.pro6
-rw-r--r--tests/auto/declarative/qmlinstruction/tst_qmlinstruction.cpp585
-rw-r--r--tests/auto/declarative/qmllanguage/data/component.5.errors.txt1
-rw-r--r--tests/auto/declarative/qmllanguage/data/script.10.errors.txt1
-rw-r--r--tests/auto/declarative/qmllanguage/data/script.12.errors.txt1
-rw-r--r--tests/auto/declarative/qmllanguage/data/script.9.errors.txt1
-rw-r--r--tests/auto/declarative/qmllanguage/qmllanguage.pro14
-rw-r--r--tests/auto/declarative/qmllanguage/testtypes.cpp59
-rw-r--r--tests/auto/declarative/qmllanguage/testtypes.h545
-rw-r--r--tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp1383
-rw-r--r--tests/auto/declarative/qmllist/qmllist.pro5
-rw-r--r--tests/auto/declarative/qmllist/tst_qmllist.cpp574
-rw-r--r--tests/auto/declarative/qmllistmodel/qmllistmodel.pro6
-rw-r--r--tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp338
-rw-r--r--tests/auto/declarative/qmlmetaproperty/qmlmetaproperty.pro5
-rw-r--r--tests/auto/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp1136
-rw-r--r--tests/auto/declarative/qmlmetatype/qmlmetatype.pro6
-rw-r--r--tests/auto/declarative/qmlmetatype/tst_qmlmetatype.cpp371
-rw-r--r--tests/auto/declarative/qmlmoduleplugin/plugin/plugin.cpp84
-rw-r--r--tests/auto/declarative/qmlmoduleplugin/plugin/plugin.pro5
-rw-r--r--tests/auto/declarative/qmlmoduleplugin/qmlmoduleplugin.pro7
-rw-r--r--tests/auto/declarative/qmlmoduleplugin/tst_qmlmoduleplugin.cpp117
-rw-r--r--tests/auto/declarative/qmlmoduleplugin/tst_qmlmoduleplugin.pro4
-rw-r--r--tests/auto/declarative/qmlnumberformatter/qmlnumberformatter.pro5
-rw-r--r--tests/auto/declarative/qmlnumberformatter/tst_qmlnumberformatter.cpp222
-rw-r--r--tests/auto/declarative/qmlpixmapcache/qmlpixmapcache.pro9
-rw-r--r--tests/auto/declarative/qmlpixmapcache/tst_qmlpixmapcache.cpp282
-rw-r--r--tests/auto/declarative/qmlpropertymap/qmlpropertymap.pro5
-rw-r--r--tests/auto/declarative/qmlpropertymap/tst_qmlpropertymap.cpp171
-rw-r--r--tests/auto/declarative/qmlqt/qmlqt.pro9
-rw-r--r--tests/auto/declarative/qmlqt/tst_qmlqt.cpp369
-rw-r--r--tests/auto/declarative/qmlspringfollow/qmlspringfollow.pro8
-rw-r--r--tests/auto/declarative/qmlspringfollow/tst_qmlspringfollow.cpp137
-rw-r--r--tests/auto/declarative/qmlstates/qmlstates.pro8
-rw-r--r--tests/auto/declarative/qmlstates/tst_qmlstates.cpp911
-rw-r--r--tests/auto/declarative/qmlsystempalette/qmlsystempalette.pro5
-rw-r--r--tests/auto/declarative/qmlsystempalette/tst_qmlsystempalette.cpp187
-rw-r--r--tests/auto/declarative/qmltimer/qmltimer.pro7
-rw-r--r--tests/auto/declarative/qmltimer/tst_qmltimer.cpp285
-rw-r--r--tests/auto/declarative/qmlvaluetypes/qmlvaluetypes.pro10
-rw-r--r--tests/auto/declarative/qmlvaluetypes/testtypes.cpp45
-rw-r--r--tests/auto/declarative/qmlvaluetypes/testtypes.h152
-rw-r--r--tests/auto/declarative/qmlvaluetypes/tst_qmlvaluetypes.cpp588
-rw-r--r--tests/auto/declarative/qmlxmlhttprequest/qmlxmlhttprequest.pro13
-rw-r--r--tests/auto/declarative/qmlxmlhttprequest/tst_qmlxmlhttprequest.cpp1315
-rw-r--r--tests/auto/declarative/qmlxmllistmodel/qmlxmllistmodel.pro11
-rw-r--r--tests/auto/declarative/qmlxmllistmodel/tst_qmlxmllistmodel.cpp203
-rw-r--r--tests/auto/declarative/qpacketprotocol/tst_qpacketprotocol.cpp12
-rw-r--r--tests/auto/declarative/shared/debugutil.cpp52
-rw-r--r--tests/auto/declarative/shared/debugutil_p.h52
-rw-r--r--tests/auto/declarative/sql/tst_sql.cpp18
-rw-r--r--tests/auto/declarative/visual/Package_Views/packageviews.qml2
-rw-r--r--tests/auto/declarative/visual/animation/easing/easing.qml84
-rw-r--r--tests/auto/declarative/visual/animation/pauseAnimation/pauseAnimation.qml4
-rw-r--r--tests/auto/declarative/visual/animation/propertyAction/propertyAction.qml2
-rw-r--r--tests/auto/declarative/visual/animation/scriptAction/scriptAction.qml4
-rw-r--r--tests/auto/declarative/visual/qdeclarativeborderimage/animated-smooth.qml (renamed from tests/auto/declarative/visual/qmlgraphicsborderimage/animated-smooth.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativeborderimage/animated.qml (renamed from tests/auto/declarative/visual/qmlgraphicsborderimage/animated.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativeborderimage/borders.qml (renamed from tests/auto/declarative/visual/qmlgraphicsborderimage/borders.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativeborderimage/content/MyBorderImage.qml38
-rw-r--r--tests/auto/declarative/visual/qdeclarativeborderimage/content/bw.png (renamed from tests/auto/declarative/visual/qmlgraphicsborderimage/content/bw.png)bin1357 -> 1357 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativeborderimage/content/colors-round.sci (renamed from tests/auto/declarative/visual/qmlgraphicsborderimage/content/colors-round.sci)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativeborderimage/content/colors-stretch.sci (renamed from tests/auto/declarative/visual/qmlgraphicsborderimage/content/colors-stretch.sci)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativeborderimage/content/colors.pngbin0 -> 1655 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativeborderimage/data/animated-smooth.0.png (renamed from tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated-smooth.0.png)bin61731 -> 61731 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativeborderimage/data/animated-smooth.1.png (renamed from tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated-smooth.1.png)bin98912 -> 98912 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativeborderimage/data/animated-smooth.2.png (renamed from tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated-smooth.2.png)bin48780 -> 48780 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativeborderimage/data/animated-smooth.3.png (renamed from tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated-smooth.3.png)bin32431 -> 32431 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativeborderimage/data/animated-smooth.4.png (renamed from tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated-smooth.4.png)bin35835 -> 35835 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativeborderimage/data/animated-smooth.5.png (renamed from tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated-smooth.5.png)bin79428 -> 79428 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativeborderimage/data/animated-smooth.6.png (renamed from tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated-smooth.6.png)bin45928 -> 45928 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativeborderimage/data/animated-smooth.qml (renamed from tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated-smooth.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativeborderimage/data/animated.0.png (renamed from tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated.0.png)bin23684 -> 23684 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativeborderimage/data/animated.1.png (renamed from tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated.1.png)bin29115 -> 29115 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativeborderimage/data/animated.2.png (renamed from tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated.2.png)bin27580 -> 27580 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativeborderimage/data/animated.3.png (renamed from tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated.3.png)bin14822 -> 14822 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativeborderimage/data/animated.4.png (renamed from tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated.4.png)bin21356 -> 21356 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativeborderimage/data/animated.5.png (renamed from tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated.5.png)bin31143 -> 31143 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativeborderimage/data/animated.6.png (renamed from tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated.6.png)bin26468 -> 26468 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativeborderimage/data/animated.7.png (renamed from tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated.7.png)bin16225 -> 16225 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativeborderimage/data/animated.qml (renamed from tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativeborderimage/data/borders.0.png (renamed from tests/auto/declarative/visual/qmlgraphicsborderimage/data/borders.0.png)bin23029 -> 23029 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativeborderimage/data/borders.1.png (renamed from tests/auto/declarative/visual/qmlgraphicsborderimage/data/borders.1.png)bin23029 -> 23029 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativeborderimage/data/borders.2.png (renamed from tests/auto/declarative/visual/qmlgraphicsborderimage/data/borders.2.png)bin23029 -> 23029 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativeborderimage/data/borders.3.png (renamed from tests/auto/declarative/visual/qmlgraphicsborderimage/data/borders.3.png)bin23029 -> 23029 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativeborderimage/data/borders.4.png (renamed from tests/auto/declarative/visual/qmlgraphicsborderimage/data/borders.4.png)bin23029 -> 23029 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativeborderimage/data/borders.qml (renamed from tests/auto/declarative/visual/qmlgraphicsborderimage/data/borders.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativeeasefollow/data/easefollow.0.png (renamed from tests/auto/declarative/visual/qmleasefollow/data/easefollow.0.png)bin1305 -> 1305 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativeeasefollow/data/easefollow.1.png (renamed from tests/auto/declarative/visual/qmleasefollow/data/easefollow.1.png)bin1306 -> 1306 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativeeasefollow/data/easefollow.2.png (renamed from tests/auto/declarative/visual/qmleasefollow/data/easefollow.2.png)bin1305 -> 1305 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativeeasefollow/data/easefollow.3.png (renamed from tests/auto/declarative/visual/qmleasefollow/data/easefollow.3.png)bin1303 -> 1303 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativeeasefollow/data/easefollow.4.png (renamed from tests/auto/declarative/visual/qmleasefollow/data/easefollow.4.png)bin1303 -> 1303 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativeeasefollow/data/easefollow.5.png (renamed from tests/auto/declarative/visual/qmleasefollow/data/easefollow.5.png)bin1305 -> 1305 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativeeasefollow/data/easefollow.6.png (renamed from tests/auto/declarative/visual/qmleasefollow/data/easefollow.6.png)bin1306 -> 1306 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativeeasefollow/data/easefollow.qml (renamed from tests/auto/declarative/visual/qmleasefollow/data/easefollow.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativeeasefollow/easefollow.qml (renamed from tests/auto/declarative/visual/qmleasefollow/easefollow.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-horizontal.0.png (renamed from tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-horizontal.0.png)bin1427 -> 1427 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-horizontal.1.png (renamed from tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-horizontal.1.png)bin1357 -> 1357 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-horizontal.2.png (renamed from tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-horizontal.2.png)bin1405 -> 1405 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-horizontal.3.png (renamed from tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-horizontal.3.png)bin1427 -> 1427 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-horizontal.qml (renamed from tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-horizontal.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.0.png (renamed from tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.0.png)bin1951 -> 1951 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.1.png (renamed from tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.1.png)bin1951 -> 1951 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.10.png (renamed from tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.10.png)bin1952 -> 1952 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.11.png (renamed from tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.11.png)bin1930 -> 1930 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.12.png (renamed from tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.12.png)bin1974 -> 1974 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.13.png (renamed from tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.13.png)bin1961 -> 1961 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.14.png (renamed from tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.14.png)bin1959 -> 1959 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.15.png (renamed from tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.15.png)bin1937 -> 1937 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.16.png (renamed from tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.16.png)bin1618 -> 1618 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.17.png (renamed from tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.17.png)bin1952 -> 1952 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.18.png (renamed from tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.18.png)bin1952 -> 1952 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.19.png (renamed from tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.19.png)bin1930 -> 1930 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.2.png (renamed from tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.2.png)bin1976 -> 1976 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.20.png (renamed from tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.20.png)bin1930 -> 1930 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.21.png (renamed from tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.21.png)bin1947 -> 1947 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.22.png (renamed from tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.22.png)bin1941 -> 1941 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.23.png (renamed from tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.23.png)bin1951 -> 1951 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.24.png (renamed from tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.24.png)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.3.png (renamed from tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.3.png)bin1987 -> 1987 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.4.png (renamed from tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.4.png)bin1947 -> 1947 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.5.png (renamed from tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.5.png)bin1975 -> 1975 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.6.png (renamed from tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.6.png)bin1928 -> 1928 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.7.png (renamed from tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.7.png)bin1928 -> 1928 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.8.png (renamed from tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.8.png)bin1928 -> 1928 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.9.png (renamed from tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.9.png)bin1928 -> 1928 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.qml (renamed from tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativeflickable/flickable-horizontal.qml37
-rw-r--r--tests/auto/declarative/visual/qdeclarativeflickable/flickable-vertical.qml91
-rw-r--r--tests/auto/declarative/visual/qdeclarativeflipable/data/test-flipable.0.png (renamed from tests/auto/declarative/visual/qmlgraphicsflipable/data/test-flipable.0.png)bin1090 -> 1090 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativeflipable/data/test-flipable.1.png (renamed from tests/auto/declarative/visual/qmlgraphicsflipable/data/test-flipable.1.png)bin1134 -> 1134 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativeflipable/data/test-flipable.2.png (renamed from tests/auto/declarative/visual/qmlgraphicsflipable/data/test-flipable.2.png)bin961 -> 961 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativeflipable/data/test-flipable.3.png (renamed from tests/auto/declarative/visual/qmlgraphicsflipable/data/test-flipable.3.png)bin1076 -> 1076 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativeflipable/data/test-flipable.4.png (renamed from tests/auto/declarative/visual/qmlgraphicsflipable/data/test-flipable.4.png)bin1134 -> 1134 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativeflipable/data/test-flipable.5.png (renamed from tests/auto/declarative/visual/qmlgraphicsflipable/data/test-flipable.5.png)bin969 -> 969 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativeflipable/data/test-flipable.qml (renamed from tests/auto/declarative/visual/qmlgraphicsflipable/data/test-flipable.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativeflipable/test-flipable.qml79
-rw-r--r--tests/auto/declarative/visual/qdeclarativegridview/data/gridview.0.png (renamed from tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview.0.png)bin1303 -> 1303 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativegridview/data/gridview.1.png (renamed from tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview.1.png)bin1317 -> 1317 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativegridview/data/gridview.2.png (renamed from tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview.2.png)bin1318 -> 1318 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativegridview/data/gridview.3.png (renamed from tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview.3.png)bin1306 -> 1306 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativegridview/data/gridview.4.png (renamed from tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview.4.png)bin1308 -> 1308 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativegridview/data/gridview.5.png (renamed from tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview.5.png)bin1303 -> 1303 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativegridview/data/gridview.6.png (renamed from tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview.6.png)bin1323 -> 1323 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativegridview/data/gridview.7.png (renamed from tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview.7.png)bin1325 -> 1325 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativegridview/data/gridview.8.png (renamed from tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview.8.png)bin1346 -> 1346 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativegridview/data/gridview.9.png (renamed from tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview.9.png)bin1303 -> 1303 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativegridview/data/gridview.qml (renamed from tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativegridview/data/gridview2.0.png (renamed from tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview2.0.png)bin1310 -> 1310 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativegridview/data/gridview2.1.png (renamed from tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview2.1.png)bin1322 -> 1322 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativegridview/data/gridview2.10.png (renamed from tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview2.10.png)bin1313 -> 1313 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativegridview/data/gridview2.2.png (renamed from tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview2.2.png)bin1341 -> 1341 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativegridview/data/gridview2.3.png (renamed from tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview2.3.png)bin1368 -> 1368 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativegridview/data/gridview2.4.png (renamed from tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview2.4.png)bin1319 -> 1319 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativegridview/data/gridview2.5.png (renamed from tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview2.5.png)bin1352 -> 1352 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativegridview/data/gridview2.6.png (renamed from tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview2.6.png)bin1309 -> 1309 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativegridview/data/gridview2.7.png (renamed from tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview2.7.png)bin1347 -> 1347 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativegridview/data/gridview2.8.png (renamed from tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview2.8.png)bin1310 -> 1310 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativegridview/data/gridview2.9.png (renamed from tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview2.9.png)bin1354 -> 1354 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativegridview/data/gridview2.qml (renamed from tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview2.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativegridview/gridview.qml (renamed from tests/auto/declarative/visual/qmlgraphicsgridview/gridview.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativegridview/gridview2.qml (renamed from tests/auto/declarative/visual/qmlgraphicsgridview/gridview2.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativemouseregion/data/drag.0.png (renamed from tests/auto/declarative/visual/qmlmouseregion/data/drag.0.png)bin1563 -> 1563 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativemouseregion/data/drag.1.png (renamed from tests/auto/declarative/visual/qmlmouseregion/data/drag.1.png)bin1570 -> 1570 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativemouseregion/data/drag.2.png (renamed from tests/auto/declarative/visual/qmlmouseregion/data/drag.2.png)bin1553 -> 1553 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativemouseregion/data/drag.3.png (renamed from tests/auto/declarative/visual/qmlmouseregion/data/drag.3.png)bin1563 -> 1563 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativemouseregion/data/drag.4.png (renamed from tests/auto/declarative/visual/qmlmouseregion/data/drag.4.png)bin1569 -> 1569 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativemouseregion/data/drag.5.png (renamed from tests/auto/declarative/visual/qmlmouseregion/data/drag.5.png)bin1569 -> 1569 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativemouseregion/data/drag.6.png (renamed from tests/auto/declarative/visual/qmlmouseregion/data/drag.6.png)bin1566 -> 1566 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativemouseregion/data/drag.7.png (renamed from tests/auto/declarative/visual/qmlmouseregion/data/drag.7.png)bin1566 -> 1566 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativemouseregion/data/drag.8.png (renamed from tests/auto/declarative/visual/qmlmouseregion/data/drag.8.png)bin1567 -> 1567 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativemouseregion/data/drag.qml (renamed from tests/auto/declarative/visual/qmlmouseregion/data/drag.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.0.png (renamed from tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.0.png)bin471 -> 471 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.1.png (renamed from tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.1.png)bin474 -> 474 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.10.png (renamed from tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.10.png)bin479 -> 479 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.11.png (renamed from tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.11.png)bin479 -> 479 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.12.png (renamed from tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.12.png)bin479 -> 479 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.13.png (renamed from tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.13.png)bin479 -> 479 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.14.png (renamed from tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.14.png)bin479 -> 479 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.15.png (renamed from tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.15.png)bin479 -> 479 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.16.png (renamed from tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.16.png)bin1454 -> 1454 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.17.png (renamed from tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.17.png)bin1454 -> 1454 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.18.png (renamed from tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.18.png)bin1454 -> 1454 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.19.png (renamed from tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.19.png)bin1454 -> 1454 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.2.png (renamed from tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.2.png)bin474 -> 474 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.20.png (renamed from tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.20.png)bin1454 -> 1454 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.21.png (renamed from tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.21.png)bin1454 -> 1454 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.22.png (renamed from tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.22.png)bin1454 -> 1454 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.3.png (renamed from tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.3.png)bin474 -> 474 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.4.png (renamed from tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.4.png)bin481 -> 481 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.5.png (renamed from tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.5.png)bin481 -> 481 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.6.png (renamed from tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.6.png)bin481 -> 481 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.7.png (renamed from tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.7.png)bin481 -> 481 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.8.png (renamed from tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.8.png)bin479 -> 479 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.9.png (renamed from tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.9.png)bin479 -> 479 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.qml (renamed from tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativemouseregion/drag.qml (renamed from tests/auto/declarative/visual/qmlmouseregion/drag.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativemouseregion/mouseregion.qml (renamed from tests/auto/declarative/visual/qmlmouseregion/mouseregion.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativeparticles/data/particles.0.png (renamed from tests/auto/declarative/visual/qmlgraphicsparticles/data/particles.0.png)bin10219 -> 10219 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativeparticles/data/particles.1.png (renamed from tests/auto/declarative/visual/qmlgraphicsparticles/data/particles.1.png)bin13469 -> 13469 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativeparticles/data/particles.2.png (renamed from tests/auto/declarative/visual/qmlgraphicsparticles/data/particles.2.png)bin14051 -> 14051 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativeparticles/data/particles.qml (renamed from tests/auto/declarative/visual/qmlgraphicsparticles/data/particles.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativeparticles/particles.qml (renamed from tests/auto/declarative/visual/qmlgraphicsparticles/particles.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativeparticles/star.png (renamed from tests/auto/declarative/visual/qmlgraphicsparticles/star.png)bin262 -> 262 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview-2.0.png (renamed from tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview-2.0.png)bin2263 -> 2263 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview-2.1.png (renamed from tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview-2.1.png)bin2329 -> 2329 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview-2.2.png (renamed from tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview-2.2.png)bin2279 -> 2279 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview-2.3.png (renamed from tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview-2.3.png)bin2263 -> 2263 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview-2.4.png (renamed from tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview-2.4.png)bin2263 -> 2263 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview-2.5.png (renamed from tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview-2.5.png)bin2308 -> 2308 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview-2.6.png (renamed from tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview-2.6.png)bin2280 -> 2280 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview-2.qml (renamed from tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview-2.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview.0.png (renamed from tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview.0.png)bin2321 -> 2321 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview.1.png (renamed from tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview.1.png)bin2380 -> 2380 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview.2.png (renamed from tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview.2.png)bin2315 -> 2315 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview.3.png (renamed from tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview.3.png)bin2372 -> 2372 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview.4.png (renamed from tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview.4.png)bin2327 -> 2327 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview.qml (renamed from tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativepathview/test-pathview-2.qml (renamed from tests/auto/declarative/visual/qmlgraphicspathview/test-pathview-2.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativepathview/test-pathview.qml (renamed from tests/auto/declarative/visual/qmlgraphicspathview/test-pathview.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativepositioners/data/dynamic.0.png (renamed from tests/auto/declarative/visual/qmlgraphicspositioners/data/dynamic.0.png)bin1429 -> 1429 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativepositioners/data/dynamic.1.png (renamed from tests/auto/declarative/visual/qmlgraphicspositioners/data/dynamic.1.png)bin1433 -> 1433 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativepositioners/data/dynamic.2.png (renamed from tests/auto/declarative/visual/qmlgraphicspositioners/data/dynamic.2.png)bin1431 -> 1431 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativepositioners/data/dynamic.3.png (renamed from tests/auto/declarative/visual/qmlgraphicspositioners/data/dynamic.3.png)bin1428 -> 1428 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativepositioners/data/dynamic.4.png (renamed from tests/auto/declarative/visual/qmlgraphicspositioners/data/dynamic.4.png)bin1432 -> 1432 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativepositioners/data/dynamic.5.png (renamed from tests/auto/declarative/visual/qmlgraphicspositioners/data/dynamic.5.png)bin1434 -> 1434 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativepositioners/data/dynamic.qml (renamed from tests/auto/declarative/visual/qmlgraphicspositioners/data/dynamic.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativepositioners/data/repeater.0.png (renamed from tests/auto/declarative/visual/qmlgraphicspositioners/data/repeater.0.png)bin2790 -> 2790 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativepositioners/data/repeater.qml (renamed from tests/auto/declarative/visual/qmlgraphicspositioners/data/repeater.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativepositioners/dynamic.qml (renamed from tests/auto/declarative/visual/qmlgraphicspositioners/dynamic.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativepositioners/repeater.qml (renamed from tests/auto/declarative/visual/qmlgraphicspositioners/repeater.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativespringfollow/clock.qml (renamed from tests/auto/declarative/visual/qmlspringfollow/clock.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativespringfollow/content/background.png (renamed from tests/auto/declarative/visual/qmlspringfollow/content/background.png)bin46895 -> 46895 bytes
-rwxr-xr-xtests/auto/declarative/visual/qdeclarativespringfollow/content/center.png (renamed from tests/auto/declarative/visual/qmlspringfollow/content/center.png)bin765 -> 765 bytes
-rwxr-xr-xtests/auto/declarative/visual/qdeclarativespringfollow/content/clock.png (renamed from tests/auto/declarative/visual/qmlspringfollow/content/clock.png)bin20653 -> 20653 bytes
-rwxr-xr-xtests/auto/declarative/visual/qdeclarativespringfollow/content/hour.png (renamed from tests/auto/declarative/visual/qmlspringfollow/content/hour.png)bin625 -> 625 bytes
-rwxr-xr-xtests/auto/declarative/visual/qdeclarativespringfollow/content/minute.png (renamed from tests/auto/declarative/visual/qmlspringfollow/content/minute.png)bin625 -> 625 bytes
-rwxr-xr-xtests/auto/declarative/visual/qdeclarativespringfollow/content/second.png (renamed from tests/auto/declarative/visual/qmlspringfollow/content/second.png)bin303 -> 303 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativespringfollow/data/clock.0.png (renamed from tests/auto/declarative/visual/qmlspringfollow/data/clock.0.png)bin17294 -> 17294 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativespringfollow/data/clock.1.png (renamed from tests/auto/declarative/visual/qmlspringfollow/data/clock.1.png)bin17394 -> 17394 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativespringfollow/data/clock.2.png (renamed from tests/auto/declarative/visual/qmlspringfollow/data/clock.2.png)bin17524 -> 17524 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativespringfollow/data/clock.3.png (renamed from tests/auto/declarative/visual/qmlspringfollow/data/clock.3.png)bin17572 -> 17572 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativespringfollow/data/clock.qml (renamed from tests/auto/declarative/visual/qmlspringfollow/data/clock.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativespringfollow/data/follow.0.png (renamed from tests/auto/declarative/visual/qmlspringfollow/data/follow.0.png)bin959 -> 959 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativespringfollow/data/follow.1.png (renamed from tests/auto/declarative/visual/qmlspringfollow/data/follow.1.png)bin1244 -> 1244 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativespringfollow/data/follow.10.png (renamed from tests/auto/declarative/visual/qmlspringfollow/data/follow.10.png)bin1299 -> 1299 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativespringfollow/data/follow.2.png (renamed from tests/auto/declarative/visual/qmlspringfollow/data/follow.2.png)bin1224 -> 1224 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativespringfollow/data/follow.3.png (renamed from tests/auto/declarative/visual/qmlspringfollow/data/follow.3.png)bin1243 -> 1243 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativespringfollow/data/follow.4.png (renamed from tests/auto/declarative/visual/qmlspringfollow/data/follow.4.png)bin1230 -> 1230 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativespringfollow/data/follow.5.png (renamed from tests/auto/declarative/visual/qmlspringfollow/data/follow.5.png)bin1231 -> 1231 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativespringfollow/data/follow.6.png (renamed from tests/auto/declarative/visual/qmlspringfollow/data/follow.6.png)bin1239 -> 1239 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativespringfollow/data/follow.7.png (renamed from tests/auto/declarative/visual/qmlspringfollow/data/follow.7.png)bin1241 -> 1241 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativespringfollow/data/follow.8.png (renamed from tests/auto/declarative/visual/qmlspringfollow/data/follow.8.png)bin1237 -> 1237 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativespringfollow/data/follow.9.png (renamed from tests/auto/declarative/visual/qmlspringfollow/data/follow.9.png)bin1229 -> 1229 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativespringfollow/data/follow.qml (renamed from tests/auto/declarative/visual/qmlspringfollow/data/follow.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativespringfollow/follow.qml71
-rw-r--r--tests/auto/declarative/visual/qdeclarativetext/baseline/data-X11/parentanchor.qml (renamed from tests/auto/declarative/visual/qmlgraphicstext/baseline/data/parentanchor.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativetext/baseline/data/parentanchor.qml (renamed from tests/auto/declarative/visual/qmlgraphicstext/baseline/data-X11/parentanchor.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativetext/baseline/parentanchor.qml (renamed from tests/auto/declarative/visual/qmlgraphicstext/baseline/parentanchor.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativetext/elide/data-MAC/elide.0.png (renamed from tests/auto/declarative/visual/qmlgraphicstext/elide/data-MAC/elide.0.png)bin2276 -> 2276 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetext/elide/data-MAC/elide.qml (renamed from tests/auto/declarative/visual/qmlgraphicstext/elide/data-MAC/elide.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativetext/elide/data-MAC/elide2.0.png (renamed from tests/auto/declarative/visual/qmlgraphicstext/elide/data/elide2.0.png)bin4818 -> 4818 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetext/elide/data-MAC/elide2.1.png (renamed from tests/auto/declarative/visual/qmlgraphicstext/elide/data/elide2.1.png)bin4089 -> 4089 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetext/elide/data-MAC/elide2.2.png (renamed from tests/auto/declarative/visual/qmlgraphicstext/elide/data/elide2.2.png)bin3128 -> 3128 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetext/elide/data-MAC/elide2.3.png (renamed from tests/auto/declarative/visual/qmlgraphicstext/elide/data/elide2.3.png)bin1963 -> 1963 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetext/elide/data-MAC/elide2.qml (renamed from tests/auto/declarative/visual/qmlgraphicstext/elide/data-MAC/elide2.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativetext/elide/data-MAC/multilength.0.png (renamed from tests/auto/declarative/visual/qmlgraphicstext/elide/data-MAC/multilength.0.png)bin736 -> 736 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetext/elide/data-MAC/multilength.qml (renamed from tests/auto/declarative/visual/qmlgraphicstext/elide/data-MAC/multilength.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativetext/elide/data-X11/elide.0.png (renamed from tests/auto/declarative/visual/qmlgraphicstext/elide/data-X11/elide.0.png)bin1002 -> 1002 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetext/elide/data-X11/elide.qml (renamed from tests/auto/declarative/visual/qmlgraphicstext/elide/data-X11/elide.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativetext/elide/data-X11/multilength.0.png (renamed from tests/auto/declarative/visual/qmlgraphicstext/elide/data-X11/multilength.0.png)bin596 -> 596 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetext/elide/data-X11/multilength.qml (renamed from tests/auto/declarative/visual/qmlgraphicstext/elide/data-X11/multilength.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativetext/elide/data/elide.0.png (renamed from tests/auto/declarative/visual/qmlgraphicstext/elide/data/elide.0.png)bin1604 -> 1604 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetext/elide/data/elide.qml (renamed from tests/auto/declarative/visual/qmlgraphicstext/elide/data/elide.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativetext/elide/data/elide2.0.png (renamed from tests/auto/declarative/visual/qmlgraphicstext/elide/data-MAC/elide2.0.png)bin4818 -> 4818 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetext/elide/data/elide2.1.png (renamed from tests/auto/declarative/visual/qmlgraphicstext/elide/data-MAC/elide2.1.png)bin4089 -> 4089 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetext/elide/data/elide2.2.png (renamed from tests/auto/declarative/visual/qmlgraphicstext/elide/data-MAC/elide2.2.png)bin3128 -> 3128 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetext/elide/data/elide2.3.png (renamed from tests/auto/declarative/visual/qmlgraphicstext/elide/data-MAC/elide2.3.png)bin1963 -> 1963 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetext/elide/data/elide2.qml (renamed from tests/auto/declarative/visual/qmlgraphicstext/elide/data/elide2.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativetext/elide/elide.qml (renamed from tests/auto/declarative/visual/qmlgraphicstext/elide/elide.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativetext/elide/elide2.qml (renamed from tests/auto/declarative/visual/qmlgraphicstext/elide/elide2.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativetext/elide/multilength.qml (renamed from tests/auto/declarative/visual/qmlgraphicstext/elide/multilength.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativetext/font/data-MAC/plaintext.0.png (renamed from tests/auto/declarative/visual/qmlgraphicstext/font/data-MAC/plaintext.0.png)bin103018 -> 103018 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetext/font/data-MAC/plaintext.qml (renamed from tests/auto/declarative/visual/qmlgraphicstext/font/data-MAC/plaintext.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativetext/font/data-MAC/richtext.0.png (renamed from tests/auto/declarative/visual/qmlgraphicstext/font/data-MAC/richtext.0.png)bin136492 -> 136492 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetext/font/data-MAC/richtext.qml (renamed from tests/auto/declarative/visual/qmlgraphicstext/font/data-MAC/richtext.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativetext/font/data/plaintext.0.png (renamed from tests/auto/declarative/visual/qmlgraphicstext/font/data/plaintext.0.png)bin94120 -> 94120 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetext/font/data/plaintext.qml (renamed from tests/auto/declarative/visual/qmlgraphicstext/font/data/plaintext.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativetext/font/data/richtext.0.png (renamed from tests/auto/declarative/visual/qmlgraphicstext/font/data/richtext.0.png)bin121122 -> 121122 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetext/font/data/richtext.qml (renamed from tests/auto/declarative/visual/qmlgraphicstext/font/data/richtext.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativetext/font/plaintext.qml (renamed from tests/auto/declarative/visual/qmlgraphicstext/font/plaintext.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativetext/font/richtext.qml (renamed from tests/auto/declarative/visual/qmlgraphicstext/font/richtext.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/cursorDelegate.qml35
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/cursorDelegate.0.png (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/cursorDelegate.0.png)bin793 -> 793 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/cursorDelegate.1.png (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/cursorDelegate.1.png)bin795 -> 795 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/cursorDelegate.2.png (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/cursorDelegate.2.png)bin803 -> 803 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/cursorDelegate.3.png (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/cursorDelegate.3.png)bin805 -> 805 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/cursorDelegate.4.png (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/cursorDelegate.4.png)bin805 -> 805 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/cursorDelegate.5.png (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/cursorDelegate.5.png)bin805 -> 805 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/cursorDelegate.6.png (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/cursorDelegate.6.png)bin799 -> 799 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/cursorDelegate.7.png (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/cursorDelegate.7.png)bin799 -> 799 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/cursorDelegate.8.png (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/cursorDelegate.8.png)bin803 -> 803 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/cursorDelegate.qml (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/cursorDelegate.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/qt-669.0.png (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/qt-669.0.png)bin365 -> 365 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/qt-669.1.png (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/qt-669.1.png)bin365 -> 365 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/qt-669.2.png (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/qt-669.2.png)bin366 -> 366 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/qt-669.3.png (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/qt-669.3.png)bin362 -> 362 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/qt-669.qml (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/qt-669.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data-X11/wrap.0.png (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data/wrap.0.png)bin1110 -> 1110 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data-X11/wrap.1.png (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data/wrap.1.png)bin1110 -> 1110 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data-X11/wrap.2.png (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data/wrap.2.png)bin1110 -> 1110 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data-X11/wrap.3.png (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data/wrap.3.png)bin1110 -> 1110 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data-X11/wrap.4.png (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data/wrap.4.png)bin1110 -> 1110 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data-X11/wrap.5.png (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data/wrap.5.png)bin1110 -> 1110 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data-X11/wrap.6.png (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data/wrap.6.png)bin1110 -> 1110 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data-X11/wrap.qml (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data-X11/wrap.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data/cursorDelegate.0.png (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data/cursorDelegate.0.png)bin3322 -> 3322 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data/cursorDelegate.1.png (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data/cursorDelegate.1.png)bin3323 -> 3323 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data/cursorDelegate.2.png (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data/cursorDelegate.2.png)bin3325 -> 3325 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data/cursorDelegate.3.png (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data/cursorDelegate.3.png)bin3332 -> 3332 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data/cursorDelegate.4.png (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data/cursorDelegate.4.png)bin3329 -> 3329 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data/cursorDelegate.5.png (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data/cursorDelegate.5.png)bin3818 -> 3818 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data/cursorDelegate.6.png (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data/cursorDelegate.6.png)bin3333 -> 3333 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data/cursorDelegate.7.png (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data/cursorDelegate.7.png)bin3332 -> 3332 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data/cursorDelegate.8.png (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data/cursorDelegate.8.png)bin3347 -> 3347 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data/cursorDelegate.qml (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data/cursorDelegate.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data/qt-669.0.png (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data/qt-669.0.png)bin4802 -> 4802 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data/qt-669.1.png (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data/qt-669.1.png)bin4804 -> 4804 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data/qt-669.2.png (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data/qt-669.2.png)bin4801 -> 4801 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data/qt-669.3.png (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data/qt-669.3.png)bin4791 -> 4791 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data/qt-669.qml (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data/qt-669.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data/wrap.0.png (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data-X11/wrap.0.png)bin1110 -> 1110 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data/wrap.1.png (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data-X11/wrap.1.png)bin1110 -> 1110 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data/wrap.2.png (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data-X11/wrap.2.png)bin1110 -> 1110 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data/wrap.3.png (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data-X11/wrap.3.png)bin1110 -> 1110 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data/wrap.4.png (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data-X11/wrap.4.png)bin1110 -> 1110 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data/wrap.5.png (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data-X11/wrap.5.png)bin1110 -> 1110 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data/wrap.6.png (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data-X11/wrap.6.png)bin1110 -> 1110 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/data/wrap.qml (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/data/wrap.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/qt-669.qml (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/qt-669.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextedit/wrap.qml (renamed from tests/auto/declarative/visual/qmlgraphicstextedit/wrap.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextinput/cursorDelegate.qml35
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextinput/data-MAC/cursorDelegate.0.png (renamed from tests/auto/declarative/visual/qmlgraphicstextinput/data-MAC/cursorDelegate.0.png)bin793 -> 793 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextinput/data-MAC/cursorDelegate.1.png (renamed from tests/auto/declarative/visual/qmlgraphicstextinput/data-MAC/cursorDelegate.1.png)bin796 -> 796 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextinput/data-MAC/cursorDelegate.2.png (renamed from tests/auto/declarative/visual/qmlgraphicstextinput/data-MAC/cursorDelegate.2.png)bin804 -> 804 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextinput/data-MAC/cursorDelegate.3.png (renamed from tests/auto/declarative/visual/qmlgraphicstextinput/data-MAC/cursorDelegate.3.png)bin805 -> 805 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextinput/data-MAC/cursorDelegate.4.png (renamed from tests/auto/declarative/visual/qmlgraphicstextinput/data-MAC/cursorDelegate.4.png)bin805 -> 805 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextinput/data-MAC/cursorDelegate.5.png (renamed from tests/auto/declarative/visual/qmlgraphicstextinput/data-MAC/cursorDelegate.5.png)bin805 -> 805 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextinput/data-MAC/cursorDelegate.6.png (renamed from tests/auto/declarative/visual/qmlgraphicstextinput/data-MAC/cursorDelegate.6.png)bin801 -> 801 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextinput/data-MAC/cursorDelegate.7.png (renamed from tests/auto/declarative/visual/qmlgraphicstextinput/data-MAC/cursorDelegate.7.png)bin802 -> 802 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextinput/data-MAC/cursorDelegate.8.png (renamed from tests/auto/declarative/visual/qmlgraphicstextinput/data-MAC/cursorDelegate.8.png)bin802 -> 802 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextinput/data-MAC/cursorDelegate.qml (renamed from tests/auto/declarative/visual/qmlgraphicstextinput/data-MAC/cursorDelegate.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextinput/data-X11/echoMode.0.png (renamed from tests/auto/declarative/visual/qmlgraphicstextinput/data/echoMode.0.png)bin999 -> 999 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextinput/data-X11/echoMode.1.png (renamed from tests/auto/declarative/visual/qmlgraphicstextinput/data/echoMode.1.png)bin1880 -> 1880 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextinput/data-X11/echoMode.2.png (renamed from tests/auto/declarative/visual/qmlgraphicstextinput/data/echoMode.2.png)bin2962 -> 2962 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextinput/data-X11/echoMode.3.png (renamed from tests/auto/declarative/visual/qmlgraphicstextinput/data/echoMode.3.png)bin2827 -> 2827 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextinput/data-X11/echoMode.4.png (renamed from tests/auto/declarative/visual/qmlgraphicstextinput/data/echoMode.4.png)bin2827 -> 2827 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextinput/data-X11/echoMode.qml (renamed from tests/auto/declarative/visual/qmlgraphicstextinput/data-X11/echoMode.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextinput/data-X11/hAlign.0.png (renamed from tests/auto/declarative/visual/qmlgraphicstextinput/data/hAlign.0.png)bin1245 -> 1245 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextinput/data-X11/hAlign.qml (renamed from tests/auto/declarative/visual/qmlgraphicstextinput/data/hAlign.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextinput/data/cursorDelegate.0.png (renamed from tests/auto/declarative/visual/qmlgraphicstextinput/data/cursorDelegate.0.png)bin3314 -> 3314 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextinput/data/cursorDelegate.1.png (renamed from tests/auto/declarative/visual/qmlgraphicstextinput/data/cursorDelegate.1.png)bin3377 -> 3377 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextinput/data/cursorDelegate.2.png (renamed from tests/auto/declarative/visual/qmlgraphicstextinput/data/cursorDelegate.2.png)bin3323 -> 3323 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextinput/data/cursorDelegate.3.png (renamed from tests/auto/declarative/visual/qmlgraphicstextinput/data/cursorDelegate.3.png)bin3325 -> 3325 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextinput/data/cursorDelegate.4.png (renamed from tests/auto/declarative/visual/qmlgraphicstextinput/data/cursorDelegate.4.png)bin3322 -> 3322 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextinput/data/cursorDelegate.5.png (renamed from tests/auto/declarative/visual/qmlgraphicstextinput/data/cursorDelegate.5.png)bin3322 -> 3322 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextinput/data/cursorDelegate.6.png (renamed from tests/auto/declarative/visual/qmlgraphicstextinput/data/cursorDelegate.6.png)bin3326 -> 3326 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextinput/data/cursorDelegate.7.png (renamed from tests/auto/declarative/visual/qmlgraphicstextinput/data/cursorDelegate.7.png)bin3814 -> 3814 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextinput/data/cursorDelegate.8.png (renamed from tests/auto/declarative/visual/qmlgraphicstextinput/data/cursorDelegate.8.png)bin3324 -> 3324 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextinput/data/cursorDelegate.qml (renamed from tests/auto/declarative/visual/qmlgraphicstextinput/data/cursorDelegate.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextinput/data/echoMode.0.png (renamed from tests/auto/declarative/visual/qmlgraphicstextinput/data-X11/echoMode.0.png)bin999 -> 999 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextinput/data/echoMode.1.png (renamed from tests/auto/declarative/visual/qmlgraphicstextinput/data-X11/echoMode.1.png)bin1880 -> 1880 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextinput/data/echoMode.2.png (renamed from tests/auto/declarative/visual/qmlgraphicstextinput/data-X11/echoMode.2.png)bin2962 -> 2962 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextinput/data/echoMode.3.png (renamed from tests/auto/declarative/visual/qmlgraphicstextinput/data-X11/echoMode.3.png)bin2827 -> 2827 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextinput/data/echoMode.4.png (renamed from tests/auto/declarative/visual/qmlgraphicstextinput/data-X11/echoMode.4.png)bin2827 -> 2827 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextinput/data/echoMode.qml (renamed from tests/auto/declarative/visual/qmlgraphicstextinput/data/echoMode.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextinput/data/hAlign.0.png (renamed from tests/auto/declarative/visual/qmlgraphicstextinput/data-X11/hAlign.0.png)bin1245 -> 1245 bytes
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextinput/data/hAlign.qml (renamed from tests/auto/declarative/visual/qmlgraphicstextinput/data-X11/hAlign.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextinput/echoMode.qml (renamed from tests/auto/declarative/visual/qmlgraphicstextinput/echoMode.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativetextinput/hAlign.qml (renamed from tests/auto/declarative/visual/qmlgraphicstextinput/hAlign.qml)0
-rw-r--r--tests/auto/declarative/visual/qmlgraphicsborderimage/content/MyBorderImage.qml38
-rw-r--r--tests/auto/declarative/visual/qmlgraphicsflickable/flickable-horizontal.qml37
-rw-r--r--tests/auto/declarative/visual/qmlgraphicsflickable/flickable-vertical.qml91
-rw-r--r--tests/auto/declarative/visual/qmlgraphicsflipable/test-flipable.qml79
-rw-r--r--tests/auto/declarative/visual/qmlgraphicstextedit/cursorDelegate.qml35
-rw-r--r--tests/auto/declarative/visual/qmlgraphicstextinput/cursorDelegate.qml35
-rw-r--r--tests/auto/declarative/visual/qmlspringfollow/follow.qml71
-rw-r--r--tests/auto/declarative/visual/tst_visual.cpp20
-rw-r--r--tests/auto/qdatastream/tst_qdatastream.cpp69
-rw-r--r--tests/auto/qdeclarativeaudio/qdeclarativeaudio.pro4
-rw-r--r--tests/auto/qdeclarativeaudio/tst_qdeclarativeaudio.cpp1200
-rw-r--r--tests/auto/qdeclarativevideo/qdeclarativevideo.pro4
-rw-r--r--tests/auto/qdeclarativevideo/tst_qdeclarativevideo.cpp911
-rw-r--r--tests/auto/qeasingcurve/tst_qeasingcurve.cpp61
-rw-r--r--tests/auto/qmlaudio/qmlaudio.pro6
-rw-r--r--tests/auto/qmlaudio/tst_qmlaudio.cpp1200
-rw-r--r--tests/auto/qmlgraphicsvideo/qmlgraphicsvideo.pro6
-rw-r--r--tests/auto/qmlgraphicsvideo/tst_qmlgraphicsvideo.cpp911
1324 files changed, 31742 insertions, 30199 deletions
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro
index 5fd2dca..95c168a 100644
--- a/tests/auto/auto.pro
+++ b/tests/auto/auto.pro
@@ -313,8 +313,6 @@ SUBDIRS += \
qmediaserviceprovider \
qmediatimerange \
qvideowidget \
- qmlaudio \
- qmlgraphicsvideo \
qspinbox \
qsplitter \
qsql \
@@ -485,6 +483,9 @@ contains(QT_CONFIG,opengl):SUBDIRS += qgl qglbuffer qgl_threads
contains(QT_CONFIG,qt3support):!wince*:SUBDIRS += $$Q3SUBDIRS
+contains(QT_CONFIG,multimedia):contains(QT_CONFIG,declarative):SUBDIRS += qdeclarativeaudio \
+ qdeclarativevideo
+
contains(QT_CONFIG, OdfWriter):SUBDIRS += qzip qtextodfwriter
mac: {
SUBDIRS += macgui \
diff --git a/tests/auto/declarative/declarative.pro b/tests/auto/declarative/declarative.pro
index 9dc7230..42ff523 100644
--- a/tests/auto/declarative/declarative.pro
+++ b/tests/auto/declarative/declarative.pro
@@ -4,64 +4,66 @@ SUBDIRS += \
layouts \ # Cover
parserstress \ # Cover
qmetaobjectbuilder \ # Cover
- qmlanimations \ # Cover
- qmlbehaviors \ # Cover
- qmlbinding \ # Cover
- qmlconnection \ # Cover
- qmlcontext \ # Cover
- qmldatetimeformatter \ # Cover
- qmldebug \ # Cover
- qmldebugclient \ # Cover
- qmldebugservice \ # Cover
- qmldom \ # Cover
- qmleasefollow \ # Cover
- qmlecmascript \ # Cover
- qmlengine \ # Cover
- qmlerror \ # Cover
- qmlfontloader \ # Cover
- qmlgraphicsanchors \ # Cover
- qmlgraphicsanimatedimage \ # Cover
- qmlgraphicsimage \ # Cover
- qmlgraphicsborderimage \ # Cover
- qmlgraphicsflickable \ # Cover
- qmlgraphicsflipable \ # Cover
- qmlgraphicsgridview \ # Cover
- qmlgraphicsitem \ # Cover
- qmlgraphicslistview \ # Cover
- qmlgraphicsloader \ # Cover
- qmlgraphicsmousearea \ # Cover
- qmlgraphicsparticles \ # Cover
- qmlgraphicspathview \ # Cover
- qmlgraphicspositioners \ # Cover
- qmlgraphicstext \ # Cover
- qmlgraphicstextedit \ # Cover
- qmlgraphicstextinput \ # Cover
- qmlinfo \ # Cover
- qmlinstruction \ # Cover
- qmllanguage \ # Cover
- qmllist \ # Cover
- qmllistmodel \ # Cover
- qmlmetaproperty \ # Cover
- qmlmetatype \ # Cover
- qmlnumberformatter \ # Cover
- qmlpixmapcache \ # Cover
- qmlpropertymap \ # Cover
- qmlqt \ # Cover
- qmlspringfollow \ # Cover
- qmlstates \ # Cover
- qmlsystempalette \ # Cover
- qmltimer \ # Cover
- qmlxmllistmodel \ # Cover
+ qdeclarativeanimations \ # Cover
+ qdeclarativebehaviors \ # Cover
+ qdeclarativebinding \ # Cover
+ qdeclarativeconnection \ # Cover
+ qdeclarativecontext \ # Cover
+ qdeclarativedatetimeformatter \ # Cover
+ qdeclarativedebug \ # Cover
+ qdeclarativedebugclient \ # Cover
+ qdeclarativedebugservice \ # Cover
+ qdeclarativedom \ # Cover
+ qdeclarativeeasefollow \ # Cover
+ qdeclarativeecmascript \ # Cover
+ qdeclarativeengine \ # Cover
+ qdeclarativeerror \ # Cover
+ qdeclarativefontloader \ # Cover
+ qdeclarativeanchors \ # Cover
+ qdeclarativeanimatedimage \ # Cover
+ qdeclarativeimage \ # Cover
+ qdeclarativeborderimage \ # Cover
+ qdeclarativeflickable \ # Cover
+ qdeclarativeflipable \ # Cover
+ qdeclarativegridview \ # Cover
+ qdeclarativeitem \ # Cover
+ qdeclarativelistview \ # Cover
+ qdeclarativeloader \ # Cover
+ qdeclarativemousearea \ # Cover
+ qdeclarativeparticles \ # Cover
+ qdeclarativepathview \ # Cover
+ qdeclarativepositioners \ # Cover
+ qdeclarativetext \ # Cover
+ qdeclarativetextedit \ # Cover
+ qdeclarativetextinput \ # Cover
+ qdeclarativeinfo \ # Cover
+ qdeclarativeinstruction \ # Cover
+ qdeclarativelanguage \ # Cover
+ qdeclarativelistreference \ # Cover
+ qdeclarativelistmodel \ # Cover
+ qdeclarativeproperty \ # Cover
+ qdeclarativemetatype \ # Cover
+ qdeclarativemoduleplugin \ # Cover
+ qdeclarativenumberformatter \ # Cover
+ qdeclarativepixmapcache \ # Cover
+ qdeclarativepropertymap \ # Cover
+ qdeclarativeqt \ # Cover
+ qdeclarativespringfollow \ # Cover
+ qdeclarativestates \ # Cover
+ qdeclarativesystempalette \ # Cover
+ qdeclarativetimer \ # Cover
+ qdeclarativexmllistmodel \ # Cover
qpacketprotocol \ # Cover
- qmlgraphicsrepeater \ # Cover
- qmlvaluetypes \ # Cover
- qmlxmlhttprequest \ # Cover
- qmlimageprovider \ # Cover
+ qdeclarativerepeater \ # Cover
+ qdeclarativevaluetypes \ # Cover
+ qdeclarativexmlhttprequest \ # Cover
+ qdeclarativeimageprovider \ # Cover
+ qdeclarativestyledtext \ # Cover
sql # Cover
contains(QT_CONFIG, webkit) {
SUBDIRS += \
- qmlgraphicswebview # Cover
+ qdeclarativewebview # Cover
}
# Tests which should run in Pulse
diff --git a/tests/auto/declarative/examples/tst_examples.cpp b/tests/auto/declarative/examples/tst_examples.cpp
index 104c2d3..6160e7c 100644
--- a/tests/auto/declarative/examples/tst_examples.cpp
+++ b/tests/auto/declarative/examples/tst_examples.cpp
@@ -56,7 +56,7 @@ private slots:
void namingConvention();
private:
- QString qmlviewer;
+ QString qmlruntime;
QStringList excludedDirs;
void namingConvention(const QDir &);
@@ -68,11 +68,11 @@ tst_examples::tst_examples()
QString binaries = QLibraryInfo::location(QLibraryInfo::BinariesPath);
#if defined(Q_WS_MAC)
- qmlviewer = QDir(binaries).absoluteFilePath("qmlviewer.app/Contents/MacOS/qmlviewer");
+ qmlruntime = QDir(binaries).absoluteFilePath("qml.app/Contents/MacOS/qml");
#elif defined(Q_WS_WIN)
- qmlviewer = QDir(binaries).absoluteFilePath("qmlviewer.exe");
+ qmlruntime = QDir(binaries).absoluteFilePath("qml.exe");
#else
- qmlviewer = QDir(binaries).absoluteFilePath("qmlviewer");
+ qmlruntime = QDir(binaries).absoluteFilePath("qml");
#endif
@@ -190,7 +190,8 @@ void tst_examples::examples()
<< "-scriptopts" << "play,testerror,exitoncomplete,exitonfailure"
<< file;
QProcess p;
- p.start(qmlviewer, arguments);
+qDebug() << qmlruntime << arguments;
+ p.start(qmlruntime, arguments);
QVERIFY(p.waitForFinished());
QCOMPARE(p.exitStatus(), QProcess::NormalExit);
QCOMPARE(p.exitCode(), 0);
diff --git a/tests/auto/declarative/graphicswidgets/data/graphicswidgets.qml b/tests/auto/declarative/graphicswidgets/data/graphicswidgets.qml
index 70fafd6..c00173d 100644
--- a/tests/auto/declarative/graphicswidgets/data/graphicswidgets.qml
+++ b/tests/auto/declarative/graphicswidgets/data/graphicswidgets.qml
@@ -1,4 +1,5 @@
import Qt 4.6
+import Qt.widgets 4.6
QGraphicsView {
objectName: "GView"
diff --git a/tests/auto/declarative/graphicswidgets/tst_graphicswidgets.cpp b/tests/auto/declarative/graphicswidgets/tst_graphicswidgets.cpp
index cb618c6..a85ceed 100644
--- a/tests/auto/declarative/graphicswidgets/tst_graphicswidgets.cpp
+++ b/tests/auto/declarative/graphicswidgets/tst_graphicswidgets.cpp
@@ -40,9 +40,9 @@
****************************************************************************/
#include <qtest.h>
#include <QFile>
-#include <QtDeclarative/qmlengine.h>
-#include <QtDeclarative/qmlcomponent.h>
-#include <private/graphicswidgets_p.h>
+#include <QtDeclarative/qdeclarativeengine.h>
+#include <QtDeclarative/qdeclarativecomponent.h>
+#include <QtGui/qgraphicsview.h>
class tst_graphicswidgets : public QObject
@@ -61,8 +61,8 @@ tst_graphicswidgets::tst_graphicswidgets()
void tst_graphicswidgets::widgets()
{
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/graphicswidgets.qml"));
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/graphicswidgets.qml"));
QGraphicsView *obj = qobject_cast<QGraphicsView*>(c.create());
QVERIFY(obj != 0);
diff --git a/tests/auto/declarative/layouts/data/layouts.qml b/tests/auto/declarative/layouts/data/layouts.qml
index 00d785d..1792500 100644
--- a/tests/auto/declarative/layouts/data/layouts.qml
+++ b/tests/auto/declarative/layouts/data/layouts.qml
@@ -1,4 +1,5 @@
import Qt 4.6
+import Qt.widgets 4.6
Item {
id: resizable
diff --git a/tests/auto/declarative/layouts/tst_layouts.cpp b/tests/auto/declarative/layouts/tst_layouts.cpp
index ee05574..942125f 100644
--- a/tests/auto/declarative/layouts/tst_layouts.cpp
+++ b/tests/auto/declarative/layouts/tst_layouts.cpp
@@ -40,39 +40,38 @@
****************************************************************************/
#include <QtTest/QtTest>
#include <private/qlistmodelinterface_p.h>
-#include <qmlview.h>
-#include <private/qmlgraphicslayoutitem_p.h>
-#include <qmlexpression.h>
+#include <qdeclarativeview.h>
+#include <private/qdeclarativelayoutitem_p.h>
+#include <qdeclarativeexpression.h>
#include <QStyle>
-class tst_QmlGraphicsLayouts : public QObject
+class tst_QDeclarativeLayouts : public QObject
{
Q_OBJECT
public:
- tst_QmlGraphicsLayouts();
+ tst_QDeclarativeLayouts();
private slots:
void test_qml();//GraphicsLayout set up in Qml
void test_cpp();//GraphicsLayout set up in C++
private:
- QmlView *createView(const QString &filename);
+ QDeclarativeView *createView(const QString &filename);
};
-tst_QmlGraphicsLayouts::tst_QmlGraphicsLayouts()
+tst_QDeclarativeLayouts::tst_QDeclarativeLayouts()
{
}
-void tst_QmlGraphicsLayouts::test_qml()
+void tst_QDeclarativeLayouts::test_qml()
{
- QmlView *canvas = createView(SRCDIR "/data/layouts.qml");
+ QDeclarativeView *canvas = createView(SRCDIR "/data/layouts.qml");
- canvas->execute();
qApp->processEvents();
- QmlGraphicsLayoutItem *left = static_cast<QmlGraphicsLayoutItem*>(canvas->rootObject()->findChild<QmlGraphicsItem*>("left"));
+ QDeclarativeLayoutItem *left = static_cast<QDeclarativeLayoutItem*>(canvas->rootObject()->findChild<QDeclarativeItem*>("left"));
QVERIFY(left != 0);
- QmlGraphicsLayoutItem *right = static_cast<QmlGraphicsLayoutItem*>(canvas->rootObject()->findChild<QmlGraphicsItem*>("right"));
+ QDeclarativeLayoutItem *right = static_cast<QDeclarativeLayoutItem*>(canvas->rootObject()->findChild<QDeclarativeItem*>("right"));
QVERIFY(right != 0);
qreal l = QApplication::style()->pixelMetric(QStyle::PM_LayoutLeftMargin);
@@ -82,7 +81,7 @@ void tst_QmlGraphicsLayouts::test_qml()
QVERIFY2(l == r && r == t && t == b, "Test assumes equal margins.");
qreal gvMargin = l;
- QmlGraphicsItem *rootItem = qobject_cast<QmlGraphicsItem*>(canvas->rootObject());
+ QDeclarativeItem *rootItem = qobject_cast<QDeclarativeItem*>(canvas->rootObject());
QVERIFY(rootItem != 0);
//Preferred Size
@@ -129,20 +128,20 @@ void tst_QmlGraphicsLayouts::test_qml()
delete canvas;
}
-void tst_QmlGraphicsLayouts::test_cpp()
+void tst_QDeclarativeLayouts::test_cpp()
{
//TODO: Waiting on QT-2407 to write this test
}
-QmlView *tst_QmlGraphicsLayouts::createView(const QString &filename)
+QDeclarativeView *tst_QDeclarativeLayouts::createView(const QString &filename)
{
- QmlView *canvas = new QmlView(0);
+ QDeclarativeView *canvas = new QDeclarativeView(0);
canvas->setSource(QUrl::fromLocalFile(filename));
return canvas;
}
-QTEST_MAIN(tst_QmlGraphicsLayouts)
+QTEST_MAIN(tst_QDeclarativeLayouts)
#include "tst_layouts.moc"
diff --git a/tests/auto/declarative/parserstress/tst_parserstress.cpp b/tests/auto/declarative/parserstress/tst_parserstress.cpp
index 8af1b12..6ff5515 100644
--- a/tests/auto/declarative/parserstress/tst_parserstress.cpp
+++ b/tests/auto/declarative/parserstress/tst_parserstress.cpp
@@ -40,8 +40,8 @@
****************************************************************************/
#include <qtest.h>
-#include <QmlEngine>
-#include <QmlComponent>
+#include <QDeclarativeEngine>
+#include <QDeclarativeComponent>
#include <QDebug>
#include <QDir>
#include <QFile>
@@ -58,7 +58,7 @@ private slots:
private:
static QStringList findJSFiles(const QDir &);
- QmlEngine engine;
+ QDeclarativeEngine engine;
};
QStringList tst_parserstress::findJSFiles(const QDir &d)
@@ -130,7 +130,7 @@ void tst_parserstress::ecmascript()
QByteArray qmlData = qml.toUtf8();
- QmlComponent component(&engine);
+ QDeclarativeComponent component(&engine);
component.setData(qmlData, QUrl::fromLocalFile(SRCDIR + QString("/dummy.qml")));
QSet<QString> failingTests;
failingTests << "uc-003.js" << "uc-005.js" << "regress-352044-02-n.js"
diff --git a/tests/auto/declarative/qmlgraphicsanchors/data/anchors.qml b/tests/auto/declarative/qdeclarativeanchors/data/anchors.qml
index b64d0b0..b64d0b0 100644
--- a/tests/auto/declarative/qmlgraphicsanchors/data/anchors.qml
+++ b/tests/auto/declarative/qdeclarativeanchors/data/anchors.qml
diff --git a/tests/auto/declarative/qmlgraphicsanchors/data/centerin.qml b/tests/auto/declarative/qdeclarativeanchors/data/centerin.qml
index 09b97f6..09b97f6 100644
--- a/tests/auto/declarative/qmlgraphicsanchors/data/centerin.qml
+++ b/tests/auto/declarative/qdeclarativeanchors/data/centerin.qml
diff --git a/tests/auto/declarative/qmlgraphicsanchors/data/crash1.qml b/tests/auto/declarative/qdeclarativeanchors/data/crash1.qml
index fd9dc55..fd9dc55 100644
--- a/tests/auto/declarative/qmlgraphicsanchors/data/crash1.qml
+++ b/tests/auto/declarative/qdeclarativeanchors/data/crash1.qml
diff --git a/tests/auto/declarative/qmlgraphicsanchors/data/fill.qml b/tests/auto/declarative/qdeclarativeanchors/data/fill.qml
index 902465c..902465c 100644
--- a/tests/auto/declarative/qmlgraphicsanchors/data/fill.qml
+++ b/tests/auto/declarative/qdeclarativeanchors/data/fill.qml
diff --git a/tests/auto/declarative/qmlgraphicsanchors/data/loop1.qml b/tests/auto/declarative/qdeclarativeanchors/data/loop1.qml
index a266612..a266612 100644
--- a/tests/auto/declarative/qmlgraphicsanchors/data/loop1.qml
+++ b/tests/auto/declarative/qdeclarativeanchors/data/loop1.qml
diff --git a/tests/auto/declarative/qmlgraphicsanchors/data/loop2.qml b/tests/auto/declarative/qdeclarativeanchors/data/loop2.qml
index acb57cd..acb57cd 100644
--- a/tests/auto/declarative/qmlgraphicsanchors/data/loop2.qml
+++ b/tests/auto/declarative/qdeclarativeanchors/data/loop2.qml
diff --git a/tests/auto/declarative/qmlgraphicsanchors/data/margins.qml b/tests/auto/declarative/qdeclarativeanchors/data/margins.qml
index 4a29e77..4a29e77 100644
--- a/tests/auto/declarative/qmlgraphicsanchors/data/margins.qml
+++ b/tests/auto/declarative/qdeclarativeanchors/data/margins.qml
diff --git a/tests/auto/declarative/qdeclarativeanchors/qdeclarativeanchors.pro b/tests/auto/declarative/qdeclarativeanchors/qdeclarativeanchors.pro
new file mode 100644
index 0000000..ca2f68f
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeanchors/qdeclarativeanchors.pro
@@ -0,0 +1,6 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative
+SOURCES += tst_qdeclarativeanchors.cpp
+macx:CONFIG -= app_bundle
+
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qdeclarativeanchors/tst_qdeclarativeanchors.cpp b/tests/auto/declarative/qdeclarativeanchors/tst_qdeclarativeanchors.cpp
new file mode 100644
index 0000000..9d8ba6c
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeanchors/tst_qdeclarativeanchors.cpp
@@ -0,0 +1,448 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QSignalSpy>
+#include <QtDeclarative/qdeclarativeengine.h>
+#include <QtDeclarative/qdeclarativecomponent.h>
+#include <QtDeclarative/qdeclarativeview.h>
+#include <private/qdeclarativerectangle_p.h>
+#include <private/qdeclarativetext_p.h>
+#include <QtDeclarative/private/qdeclarativeanchors_p_p.h>
+
+Q_DECLARE_METATYPE(QDeclarativeAnchors::UsedAnchor)
+Q_DECLARE_METATYPE(QDeclarativeAnchorLine::AnchorLine)
+
+
+class tst_qdeclarativeanchors : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qdeclarativeanchors() {}
+
+ template<typename T>
+ T *findItem(QGraphicsObject *parent, const QString &id);
+
+private slots:
+ void basicAnchors();
+ void loops();
+ void illegalSets();
+ void illegalSets_data();
+ void reset();
+ void reset_data();
+ void resetConvenience();
+ void nullItem();
+ void nullItem_data();
+ void crash1();
+ void centerIn();
+ void fill();
+ void margins();
+};
+
+/*
+ Find an item with the specified id.
+*/
+template<typename T>
+T *tst_qdeclarativeanchors::findItem(QGraphicsObject *parent, const QString &objectName)
+{
+ const QMetaObject &mo = T::staticMetaObject;
+ QList<QGraphicsItem *> children = parent->childItems();
+ for (int i = 0; i < children.count(); ++i) {
+ QDeclarativeItem *item = qobject_cast<QDeclarativeItem *>(children.at(i)->toGraphicsObject());
+ if (item) {
+ if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) {
+ return static_cast<T*>(item);
+ }
+ item = findItem<T>(item, objectName);
+ if (item)
+ return static_cast<T*>(item);
+ }
+ }
+
+ return 0;
+}
+
+void tst_qdeclarativeanchors::basicAnchors()
+{
+ QDeclarativeView *view = new QDeclarativeView;
+ view->setSource(QUrl::fromLocalFile(SRCDIR "/data/anchors.qml"));
+
+ qApp->processEvents();
+
+ //sibling horizontal
+ QCOMPARE(findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("rect1"))->x(), 26.0);
+ QCOMPARE(findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("rect2"))->x(), 122.0);
+ QCOMPARE(findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("rect3"))->x(), 74.0);
+ QCOMPARE(findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("rect4"))->x(), 16.0);
+ QCOMPARE(findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("rect5"))->x(), 112.0);
+ QCOMPARE(findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("rect6"))->x(), 64.0);
+
+ //parent horizontal
+ QCOMPARE(findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("rect7"))->x(), 0.0);
+ QCOMPARE(findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("rect8"))->x(), 240.0);
+ QCOMPARE(findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("rect9"))->x(), 120.0);
+ QCOMPARE(findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("rect10"))->x(), -10.0);
+ QCOMPARE(findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("rect11"))->x(), 230.0);
+ QCOMPARE(findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("rect12"))->x(), 110.0);
+
+ //vertical
+ QCOMPARE(findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("rect13"))->y(), 20.0);
+ QCOMPARE(findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("rect14"))->y(), 155.0);
+
+ //stretch
+ QCOMPARE(findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("rect15"))->x(), 26.0);
+ QCOMPARE(findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("rect15"))->width(), 96.0);
+ QCOMPARE(findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("rect16"))->x(), 26.0);
+ QCOMPARE(findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("rect16"))->width(), 192.0);
+ QCOMPARE(findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("rect17"))->x(), -70.0);
+ QCOMPARE(findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("rect17"))->width(), 192.0);
+
+ //vertical stretch
+ QCOMPARE(findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("rect18"))->y(), 20.0);
+ QCOMPARE(findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("rect18"))->height(), 40.0);
+
+ //more parent horizontal
+ QCOMPARE(findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("rect19"))->x(), 115.0);
+ QCOMPARE(findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("rect20"))->x(), 235.0);
+ QCOMPARE(findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("rect21"))->x(), -5.0);
+
+ //centerIn
+ QCOMPARE(findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("rect22"))->x(), 69.0);
+ QCOMPARE(findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("rect22"))->y(), 5.0);
+
+ //margins
+ QCOMPARE(findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("rect23"))->x(), 31.0);
+ QCOMPARE(findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("rect23"))->y(), 5.0);
+ QCOMPARE(findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("rect23"))->width(), 86.0);
+ QCOMPARE(findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("rect23"))->height(), 10.0);
+
+ // offsets
+ QCOMPARE(findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("rect24"))->x(), 26.0);
+ QCOMPARE(findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("rect25"))->y(), 60.0);
+ QCOMPARE(findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("rect26"))->y(), 5.0);
+
+ //baseline
+ QDeclarativeText *text1 = findItem<QDeclarativeText>(view->rootObject(), QLatin1String("text1"));
+ QDeclarativeText *text2 = findItem<QDeclarativeText>(view->rootObject(), QLatin1String("text2"));
+ QCOMPARE(text1->y(), text2->y());
+
+ delete view;
+}
+
+// mostly testing that we don't crash
+void tst_qdeclarativeanchors::loops()
+{
+ {
+ QUrl source(QUrl::fromLocalFile(SRCDIR "/data/loop1.qml"));
+
+ QString expect = "QML Text (" + source.toString() + ":6:5" + ") Possible anchor loop detected on horizontal anchor.";
+ QTest::ignoreMessage(QtWarningMsg, expect.toLatin1());
+ QTest::ignoreMessage(QtWarningMsg, expect.toLatin1());
+ QTest::ignoreMessage(QtWarningMsg, expect.toLatin1());
+
+ QDeclarativeView *view = new QDeclarativeView;
+ view->setSource(source);
+ qApp->processEvents();
+
+ delete view;
+ }
+
+ {
+ QUrl source(QUrl::fromLocalFile(SRCDIR "/data/loop2.qml"));
+
+ QString expect = "QML Image (" + source.toString() + ":8:3" + ") Possible anchor loop detected on horizontal anchor.";
+ QTest::ignoreMessage(QtWarningMsg, expect.toLatin1());
+
+ QDeclarativeView *view = new QDeclarativeView;
+ view->setSource(source);
+ qApp->processEvents();
+
+ delete view;
+ }
+}
+
+void tst_qdeclarativeanchors::illegalSets()
+{
+ QFETCH(QString, qml);
+ QFETCH(QString, warning);
+
+ QTest::ignoreMessage(QtWarningMsg, warning.toLatin1());
+
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine);
+ component.setData(QByteArray("import Qt 4.6\n" + qml.toUtf8()), QUrl::fromLocalFile(""));
+ if (!component.isReady())
+ qWarning() << "Test errors:" << component.errors();
+ QVERIFY(component.isReady());
+ QObject *o = component.create();
+ delete o;
+}
+
+void tst_qdeclarativeanchors::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 } }"
+ << "QML Rectangle (file::2:23) 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)
+ << "QML Rectangle (file::2:13) 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)
+ << "QML Rectangle (file::2:45) 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)
+ << "QML Rectangle (file::2:1) 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 } }"
+ << "QML Rectangle (file::2:23) 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; } }"
+ << "QML Text (file::2:47) 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)
+ << "QML Rectangle (file::2:13) 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)
+ << "QML Rectangle (file::2:45) 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)
+ << "QML Rectangle (file::2:1) Cannot anchor item to self.";
+ }
+
+
+ QTest::newRow("centerIn - anchor to non parent/sibling")
+ << "Rectangle { Item { Rectangle { id: rect } } Rectangle { anchors.centerIn: rect} }"
+ << "QML Rectangle (file::2:45) 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} }"
+ << "QML Rectangle (file::2:45) Cannot anchor to an item that isn't a parent or sibling.";
+}
+
+void tst_qdeclarativeanchors::reset()
+{
+ QFETCH(QString, side);
+ QFETCH(QDeclarativeAnchorLine::AnchorLine, anchorLine);
+ QFETCH(QDeclarativeAnchors::UsedAnchor, usedAnchor);
+
+ QDeclarativeItem *baseItem = new QDeclarativeItem;
+
+ QDeclarativeAnchorLine anchor;
+ anchor.item = baseItem;
+ anchor.anchorLine = anchorLine;
+
+ QDeclarativeItem *item = new QDeclarativeItem;
+
+ const QMetaObject *meta = item->anchors()->metaObject();
+ QMetaProperty p = meta->property(meta->indexOfProperty(side.toUtf8().constData()));
+
+ QVERIFY(p.write(item->anchors(), qVariantFromValue(anchor)));
+ QCOMPARE(item->anchors()->usedAnchors().testFlag(usedAnchor), true);
+
+ QVERIFY(p.reset(item->anchors()));
+ QCOMPARE(item->anchors()->usedAnchors().testFlag(usedAnchor), false);
+
+ delete item;
+ delete baseItem;
+}
+
+void tst_qdeclarativeanchors::reset_data()
+{
+ QTest::addColumn<QString>("side");
+ QTest::addColumn<QDeclarativeAnchorLine::AnchorLine>("anchorLine");
+ QTest::addColumn<QDeclarativeAnchors::UsedAnchor>("usedAnchor");
+
+ QTest::newRow("left") << "left" << QDeclarativeAnchorLine::Left << QDeclarativeAnchors::HasLeftAnchor;
+ QTest::newRow("top") << "top" << QDeclarativeAnchorLine::Top << QDeclarativeAnchors::HasTopAnchor;
+ QTest::newRow("right") << "right" << QDeclarativeAnchorLine::Right << QDeclarativeAnchors::HasRightAnchor;
+ QTest::newRow("bottom") << "bottom" << QDeclarativeAnchorLine::Bottom << QDeclarativeAnchors::HasBottomAnchor;
+
+ QTest::newRow("hcenter") << "horizontalCenter" << QDeclarativeAnchorLine::HCenter << QDeclarativeAnchors::HasHCenterAnchor;
+ QTest::newRow("vcenter") << "verticalCenter" << QDeclarativeAnchorLine::VCenter << QDeclarativeAnchors::HasVCenterAnchor;
+ QTest::newRow("baseline") << "baseline" << QDeclarativeAnchorLine::Baseline << QDeclarativeAnchors::HasBaselineAnchor;
+}
+
+void tst_qdeclarativeanchors::resetConvenience()
+{
+ QDeclarativeItem *baseItem = new QDeclarativeItem;
+ QDeclarativeItem *item = new QDeclarativeItem;
+
+ //fill
+ item->anchors()->setFill(baseItem);
+ QVERIFY(item->anchors()->fill() == baseItem);
+ item->anchors()->resetFill();
+ QVERIFY(item->anchors()->fill() == 0);
+
+ //centerIn
+ item->anchors()->setCenterIn(baseItem);
+ QVERIFY(item->anchors()->centerIn() == baseItem);
+ item->anchors()->resetCenterIn();
+ QVERIFY(item->anchors()->centerIn() == 0);
+
+ delete item;
+ delete baseItem;
+}
+
+void tst_qdeclarativeanchors::nullItem()
+{
+ QFETCH(QString, side);
+
+ QDeclarativeAnchorLine anchor;
+ QDeclarativeItem *item = new QDeclarativeItem;
+
+ const QMetaObject *meta = item->anchors()->metaObject();
+ QMetaProperty p = meta->property(meta->indexOfProperty(side.toUtf8().constData()));
+
+ QTest::ignoreMessage(QtWarningMsg, "QML Item (unknown location) Cannot anchor to a null item.");
+ QVERIFY(p.write(item->anchors(), qVariantFromValue(anchor)));
+
+ delete item;
+}
+
+void tst_qdeclarativeanchors::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";
+}
+
+void tst_qdeclarativeanchors::crash1()
+{
+ QUrl source(QUrl::fromLocalFile(SRCDIR "/data/crash1.qml"));
+
+ QString expect = "QML Text (" + source.toString() + ":4:5" + ") Possible anchor loop detected on fill.";
+ QTest::ignoreMessage(QtWarningMsg, expect.toLatin1());
+ QTest::ignoreMessage(QtWarningMsg, expect.toLatin1()); // XXX ideally, should be one message
+
+ QDeclarativeView *view = new QDeclarativeView(source);
+ qApp->processEvents();
+
+ delete view;
+}
+
+void tst_qdeclarativeanchors::fill()
+{
+ QDeclarativeView *view = new QDeclarativeView(QUrl::fromLocalFile(SRCDIR "/data/fill.qml"));
+
+ qApp->processEvents();
+ QDeclarativeRectangle* rect = findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("filler"));
+ 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 (QTBUG-6631)
+ rect->anchors()->setLeftMargin(20.0);
+ rect->anchors()->setRightMargin(0.0);
+ rect->anchors()->setBottomMargin(0.0);
+ rect->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_qdeclarativeanchors::centerIn()
+{
+ QDeclarativeView *view = new QDeclarativeView(QUrl::fromLocalFile(SRCDIR "/data/centerin.qml"));
+
+ qApp->processEvents();
+ QDeclarativeRectangle* rect = findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("centered"));
+ QCOMPARE(rect->x(), 75.0 + 10);
+ QCOMPARE(rect->y(), 75.0 + 30);
+ //Alter Offsets (QTBUG-6631)
+ rect->anchors()->setHorizontalCenterOffset(-20.0);
+ rect->anchors()->setVerticalCenterOffset(-10.0);
+ QCOMPARE(rect->x(), 75.0 - 20.0);
+ QCOMPARE(rect->y(), 75.0 - 10.0);
+
+ delete view;
+}
+
+void tst_qdeclarativeanchors::margins()
+{
+ QDeclarativeView *view = new QDeclarativeView(QUrl::fromLocalFile(SRCDIR "/data/margins.qml"));
+
+ qApp->processEvents();
+ QDeclarativeRectangle* rect = findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("filler"));
+ 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);
+
+ rect->anchors()->setTopMargin(0.0);
+ rect->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;
+}
+
+QTEST_MAIN(tst_qdeclarativeanchors)
+
+#include "tst_qdeclarativeanchors.moc"
diff --git a/tests/auto/declarative/qmlgraphicsanimatedimage/data/colors.gif b/tests/auto/declarative/qdeclarativeanimatedimage/data/colors.gif
index 1270bfa..1270bfa 100644
--- a/tests/auto/declarative/qmlgraphicsanimatedimage/data/colors.gif
+++ b/tests/auto/declarative/qdeclarativeanimatedimage/data/colors.gif
Binary files differ
diff --git a/tests/auto/declarative/qmlgraphicsanimatedimage/data/colors.qml b/tests/auto/declarative/qdeclarativeanimatedimage/data/colors.qml
index 5bada34..5bada34 100644
--- a/tests/auto/declarative/qmlgraphicsanimatedimage/data/colors.qml
+++ b/tests/auto/declarative/qdeclarativeanimatedimage/data/colors.qml
diff --git a/tests/auto/declarative/qmlgraphicsanimatedimage/data/stickman.gif b/tests/auto/declarative/qdeclarativeanimatedimage/data/stickman.gif
index 7c4cd18..7c4cd18 100644
--- a/tests/auto/declarative/qmlgraphicsanimatedimage/data/stickman.gif
+++ b/tests/auto/declarative/qdeclarativeanimatedimage/data/stickman.gif
Binary files differ
diff --git a/tests/auto/declarative/qmlgraphicsanimatedimage/data/stickman.qml b/tests/auto/declarative/qdeclarativeanimatedimage/data/stickman.qml
index a70db5d..a70db5d 100644
--- a/tests/auto/declarative/qmlgraphicsanimatedimage/data/stickman.qml
+++ b/tests/auto/declarative/qdeclarativeanimatedimage/data/stickman.qml
diff --git a/tests/auto/declarative/qmlgraphicsanimatedimage/data/stickmanpause.qml b/tests/auto/declarative/qdeclarativeanimatedimage/data/stickmanpause.qml
index 7ab17d4..7ab17d4 100644
--- a/tests/auto/declarative/qmlgraphicsanimatedimage/data/stickmanpause.qml
+++ b/tests/auto/declarative/qdeclarativeanimatedimage/data/stickmanpause.qml
diff --git a/tests/auto/declarative/qmlgraphicsanimatedimage/data/stickmanstopped.qml b/tests/auto/declarative/qdeclarativeanimatedimage/data/stickmanstopped.qml
index 53b0c3a..53b0c3a 100644
--- a/tests/auto/declarative/qmlgraphicsanimatedimage/data/stickmanstopped.qml
+++ b/tests/auto/declarative/qdeclarativeanimatedimage/data/stickmanstopped.qml
diff --git a/tests/auto/declarative/qdeclarativeanimatedimage/qdeclarativeanimatedimage.pro b/tests/auto/declarative/qdeclarativeanimatedimage/qdeclarativeanimatedimage.pro
new file mode 100644
index 0000000..2904986
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeanimatedimage/qdeclarativeanimatedimage.pro
@@ -0,0 +1,7 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative network
+HEADERS += ../shared/testhttpserver.h
+SOURCES += tst_qdeclarativeanimatedimage.cpp ../shared/testhttpserver.cpp
+macx:CONFIG -= app_bundle
+
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qdeclarativeanimatedimage/tst_qdeclarativeanimatedimage.cpp b/tests/auto/declarative/qdeclarativeanimatedimage/tst_qdeclarativeanimatedimage.cpp
new file mode 100644
index 0000000..31efc64
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeanimatedimage/tst_qdeclarativeanimatedimage.cpp
@@ -0,0 +1,191 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QtDeclarative/qdeclarativeengine.h>
+#include <QtDeclarative/qdeclarativecomponent.h>
+#include <QtDeclarative/qdeclarativeview.h>
+#include <private/qdeclarativerectangle_p.h>
+#include <private/qdeclarativeimage_p.h>
+#include <private/qdeclarativeanimatedimage_p.h>
+
+#include "../shared/testhttpserver.h"
+
+#define TRY_WAIT(expr) \
+ do { \
+ for (int ii = 0; ii < 6; ++ii) { \
+ if ((expr)) break; \
+ QTest::qWait(50); \
+ } \
+ QVERIFY((expr)); \
+ } while (false)
+
+
+class tst_qdeclarativeanimatedimage : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qdeclarativeanimatedimage() {}
+
+private slots:
+ void play();
+ void pause();
+ void stopped();
+ void setFrame();
+ void frameCount();
+ void remote();
+ void remote_data();
+ void invalidSource();
+};
+
+void tst_qdeclarativeanimatedimage::play()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/stickman.qml"));
+ QDeclarativeAnimatedImage *anim = qobject_cast<QDeclarativeAnimatedImage *>(component.create());
+ QVERIFY(anim);
+ QVERIFY(anim->isPlaying());
+
+ delete anim;
+}
+
+void tst_qdeclarativeanimatedimage::pause()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/stickmanpause.qml"));
+ QDeclarativeAnimatedImage *anim = qobject_cast<QDeclarativeAnimatedImage *>(component.create());
+ QVERIFY(anim);
+ QVERIFY(anim->isPlaying());
+ QVERIFY(anim->isPaused());
+
+ delete anim;
+}
+
+void tst_qdeclarativeanimatedimage::stopped()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/stickmanstopped.qml"));
+ QDeclarativeAnimatedImage *anim = qobject_cast<QDeclarativeAnimatedImage *>(component.create());
+ QVERIFY(anim);
+ QVERIFY(!anim->isPlaying());
+ QCOMPARE(anim->currentFrame(), 0);
+
+ delete anim;
+}
+
+void tst_qdeclarativeanimatedimage::setFrame()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/stickmanpause.qml"));
+ QDeclarativeAnimatedImage *anim = qobject_cast<QDeclarativeAnimatedImage *>(component.create());
+ QVERIFY(anim);
+ QVERIFY(anim->isPlaying());
+ QCOMPARE(anim->currentFrame(), 2);
+
+ delete anim;
+}
+
+void tst_qdeclarativeanimatedimage::frameCount()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/colors.qml"));
+ QDeclarativeAnimatedImage *anim = qobject_cast<QDeclarativeAnimatedImage *>(component.create());
+ QVERIFY(anim);
+ QVERIFY(anim->isPlaying());
+ QCOMPARE(anim->frameCount(), 3);
+
+ delete anim;
+}
+
+void tst_qdeclarativeanimatedimage::remote()
+{
+ QFETCH(QString, fileName);
+ QFETCH(bool, paused);
+
+ TestHTTPServer server(14445);
+ QVERIFY(server.isValid());
+ server.serveDirectory(SRCDIR "/data");
+
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine, QUrl("http://127.0.0.1:14445/" + fileName));
+ TRY_WAIT(component.isReady());
+
+ QDeclarativeAnimatedImage *anim = qobject_cast<QDeclarativeAnimatedImage *>(component.create());
+ QVERIFY(anim);
+
+ TRY_WAIT(anim->isPlaying());
+ if (paused) {
+ TRY_WAIT(anim->isPaused());
+ QCOMPARE(anim->currentFrame(), 2);
+ }
+
+ delete anim;
+}
+
+void tst_qdeclarativeanimatedimage::remote_data()
+{
+ QTest::addColumn<QString>("fileName");
+ QTest::addColumn<bool>("paused");
+
+ QTest::newRow("playing") << "stickman.qml" << false;
+ QTest::newRow("paused") << "stickmanpause.qml" << true;
+}
+
+void tst_qdeclarativeanimatedimage::invalidSource()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine);
+ component.setData("import Qt 4.6\n AnimatedImage { source: \"no-such-file.gif\" }", QUrl::fromLocalFile(""));
+ QVERIFY(component.isReady());
+
+ QTest::ignoreMessage(QtWarningMsg, "Error Reading Animated Image File QUrl( \"file:no-such-file.gif\" ) ");
+
+ QDeclarativeAnimatedImage *anim = qobject_cast<QDeclarativeAnimatedImage *>(component.create());
+ QVERIFY(anim);
+
+ QVERIFY(!anim->isPlaying());
+ QVERIFY(!anim->isPaused());
+ QCOMPARE(anim->currentFrame(), 0);
+ QCOMPARE(anim->frameCount(), 0);
+}
+
+QTEST_MAIN(tst_qdeclarativeanimatedimage)
+
+#include "tst_qdeclarativeanimatedimage.moc"
diff --git a/tests/auto/declarative/qmlanimations/data/attached.qml b/tests/auto/declarative/qdeclarativeanimations/data/attached.qml
index 0fb6f8c..0fb6f8c 100644
--- a/tests/auto/declarative/qmlanimations/data/attached.qml
+++ b/tests/auto/declarative/qdeclarativeanimations/data/attached.qml
diff --git a/tests/auto/declarative/qmlanimations/data/badproperty1.qml b/tests/auto/declarative/qdeclarativeanimations/data/badproperty1.qml
index d31cae9..d31cae9 100644
--- a/tests/auto/declarative/qmlanimations/data/badproperty1.qml
+++ b/tests/auto/declarative/qdeclarativeanimations/data/badproperty1.qml
diff --git a/tests/auto/declarative/qmlanimations/data/badproperty2.qml b/tests/auto/declarative/qdeclarativeanimations/data/badproperty2.qml
index 3b8b111..3b8b111 100644
--- a/tests/auto/declarative/qmlanimations/data/badproperty2.qml
+++ b/tests/auto/declarative/qdeclarativeanimations/data/badproperty2.qml
diff --git a/tests/auto/declarative/qmlanimations/data/badtype1.qml b/tests/auto/declarative/qdeclarativeanimations/data/badtype1.qml
index 6381df3..6381df3 100644
--- a/tests/auto/declarative/qmlanimations/data/badtype1.qml
+++ b/tests/auto/declarative/qdeclarativeanimations/data/badtype1.qml
diff --git a/tests/auto/declarative/qmlanimations/data/badtype2.qml b/tests/auto/declarative/qdeclarativeanimations/data/badtype2.qml
index 8d57e41..8d57e41 100644
--- a/tests/auto/declarative/qmlanimations/data/badtype2.qml
+++ b/tests/auto/declarative/qdeclarativeanimations/data/badtype2.qml
diff --git a/tests/auto/declarative/qmlanimations/data/badtype3.qml b/tests/auto/declarative/qdeclarativeanimations/data/badtype3.qml
index c4867c3..c4867c3 100644
--- a/tests/auto/declarative/qmlanimations/data/badtype3.qml
+++ b/tests/auto/declarative/qdeclarativeanimations/data/badtype3.qml
diff --git a/tests/auto/declarative/qmlanimations/data/badtype4.qml b/tests/auto/declarative/qdeclarativeanimations/data/badtype4.qml
index e80762f..e80762f 100644
--- a/tests/auto/declarative/qmlanimations/data/badtype4.qml
+++ b/tests/auto/declarative/qdeclarativeanimations/data/badtype4.qml
diff --git a/tests/auto/declarative/qmlanimations/data/dontAutoStart.qml b/tests/auto/declarative/qdeclarativeanimations/data/dontAutoStart.qml
index d9660b6..d9660b6 100644
--- a/tests/auto/declarative/qmlanimations/data/dontAutoStart.qml
+++ b/tests/auto/declarative/qdeclarativeanimations/data/dontAutoStart.qml
diff --git a/tests/auto/declarative/qmlanimations/data/dontStart.qml b/tests/auto/declarative/qdeclarativeanimations/data/dontStart.qml
index 36417db..36417db 100644
--- a/tests/auto/declarative/qmlanimations/data/dontStart.qml
+++ b/tests/auto/declarative/qdeclarativeanimations/data/dontStart.qml
diff --git a/tests/auto/declarative/qmlanimations/data/dontStart2.qml b/tests/auto/declarative/qdeclarativeanimations/data/dontStart2.qml
index 1a6540f..1a6540f 100644
--- a/tests/auto/declarative/qmlanimations/data/dontStart2.qml
+++ b/tests/auto/declarative/qdeclarativeanimations/data/dontStart2.qml
diff --git a/tests/auto/declarative/qmlanimations/data/dotproperty.qml b/tests/auto/declarative/qdeclarativeanimations/data/dotproperty.qml
index 9f0e699..9f0e699 100644
--- a/tests/auto/declarative/qmlanimations/data/dotproperty.qml
+++ b/tests/auto/declarative/qdeclarativeanimations/data/dotproperty.qml
diff --git a/tests/auto/declarative/qmlanimations/data/mixedtype1.qml b/tests/auto/declarative/qdeclarativeanimations/data/mixedtype1.qml
index 6770366..6770366 100644
--- a/tests/auto/declarative/qmlanimations/data/mixedtype1.qml
+++ b/tests/auto/declarative/qdeclarativeanimations/data/mixedtype1.qml
diff --git a/tests/auto/declarative/qmlanimations/data/mixedtype2.qml b/tests/auto/declarative/qdeclarativeanimations/data/mixedtype2.qml
index 80c9473..80c9473 100644
--- a/tests/auto/declarative/qmlanimations/data/mixedtype2.qml
+++ b/tests/auto/declarative/qdeclarativeanimations/data/mixedtype2.qml
diff --git a/tests/auto/declarative/qmlanimations/data/properties.qml b/tests/auto/declarative/qdeclarativeanimations/data/properties.qml
index 7e73f57..7e73f57 100644
--- a/tests/auto/declarative/qmlanimations/data/properties.qml
+++ b/tests/auto/declarative/qdeclarativeanimations/data/properties.qml
diff --git a/tests/auto/declarative/qmlanimations/data/properties2.qml b/tests/auto/declarative/qdeclarativeanimations/data/properties2.qml
index 6c96155..6c96155 100644
--- a/tests/auto/declarative/qmlanimations/data/properties2.qml
+++ b/tests/auto/declarative/qdeclarativeanimations/data/properties2.qml
diff --git a/tests/auto/declarative/qmlanimations/data/properties3.qml b/tests/auto/declarative/qdeclarativeanimations/data/properties3.qml
index ff08885..ff08885 100644
--- a/tests/auto/declarative/qmlanimations/data/properties3.qml
+++ b/tests/auto/declarative/qdeclarativeanimations/data/properties3.qml
diff --git a/tests/auto/declarative/qmlanimations/data/properties4.qml b/tests/auto/declarative/qdeclarativeanimations/data/properties4.qml
index dab7e5f..dab7e5f 100644
--- a/tests/auto/declarative/qmlanimations/data/properties4.qml
+++ b/tests/auto/declarative/qdeclarativeanimations/data/properties4.qml
diff --git a/tests/auto/declarative/qmlanimations/data/properties5.qml b/tests/auto/declarative/qdeclarativeanimations/data/properties5.qml
index 38396b1..38396b1 100644
--- a/tests/auto/declarative/qmlanimations/data/properties5.qml
+++ b/tests/auto/declarative/qdeclarativeanimations/data/properties5.qml
diff --git a/tests/auto/declarative/qmlanimations/data/propertiesTransition.qml b/tests/auto/declarative/qdeclarativeanimations/data/propertiesTransition.qml
index b13b94b..b13b94b 100644
--- a/tests/auto/declarative/qmlanimations/data/propertiesTransition.qml
+++ b/tests/auto/declarative/qdeclarativeanimations/data/propertiesTransition.qml
diff --git a/tests/auto/declarative/qmlanimations/data/propertiesTransition2.qml b/tests/auto/declarative/qdeclarativeanimations/data/propertiesTransition2.qml
index 033c5c1..033c5c1 100644
--- a/tests/auto/declarative/qmlanimations/data/propertiesTransition2.qml
+++ b/tests/auto/declarative/qdeclarativeanimations/data/propertiesTransition2.qml
diff --git a/tests/auto/declarative/qmlanimations/data/propertiesTransition3.qml b/tests/auto/declarative/qdeclarativeanimations/data/propertiesTransition3.qml
index d0704c9..d0704c9 100644
--- a/tests/auto/declarative/qmlanimations/data/propertiesTransition3.qml
+++ b/tests/auto/declarative/qdeclarativeanimations/data/propertiesTransition3.qml
diff --git a/tests/auto/declarative/qmlanimations/data/propertiesTransition4.qml b/tests/auto/declarative/qdeclarativeanimations/data/propertiesTransition4.qml
index e70c95c..e70c95c 100644
--- a/tests/auto/declarative/qmlanimations/data/propertiesTransition4.qml
+++ b/tests/auto/declarative/qdeclarativeanimations/data/propertiesTransition4.qml
diff --git a/tests/auto/declarative/qmlanimations/data/propertiesTransition5.qml b/tests/auto/declarative/qdeclarativeanimations/data/propertiesTransition5.qml
index b9e27da..b9e27da 100644
--- a/tests/auto/declarative/qmlanimations/data/propertiesTransition5.qml
+++ b/tests/auto/declarative/qdeclarativeanimations/data/propertiesTransition5.qml
diff --git a/tests/auto/declarative/qmlanimations/data/propertiesTransition6.qml b/tests/auto/declarative/qdeclarativeanimations/data/propertiesTransition6.qml
index 7417ed1..7417ed1 100644
--- a/tests/auto/declarative/qmlanimations/data/propertiesTransition6.qml
+++ b/tests/auto/declarative/qdeclarativeanimations/data/propertiesTransition6.qml
diff --git a/tests/auto/declarative/qmlanimations/data/valuesource.qml b/tests/auto/declarative/qdeclarativeanimations/data/valuesource.qml
index c35063d..c35063d 100644
--- a/tests/auto/declarative/qmlanimations/data/valuesource.qml
+++ b/tests/auto/declarative/qdeclarativeanimations/data/valuesource.qml
diff --git a/tests/auto/declarative/qmlanimations/data/valuesource2.qml b/tests/auto/declarative/qdeclarativeanimations/data/valuesource2.qml
index 1a60542..1a60542 100644
--- a/tests/auto/declarative/qmlanimations/data/valuesource2.qml
+++ b/tests/auto/declarative/qdeclarativeanimations/data/valuesource2.qml
diff --git a/tests/auto/declarative/qdeclarativeanimations/qdeclarativeanimations.pro b/tests/auto/declarative/qdeclarativeanimations/qdeclarativeanimations.pro
new file mode 100644
index 0000000..8eac75f
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeanimations/qdeclarativeanimations.pro
@@ -0,0 +1,6 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative
+SOURCES += tst_qdeclarativeanimations.cpp
+macx:CONFIG -= app_bundle
+
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp b/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp
new file mode 100644
index 0000000..53c63b5
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp
@@ -0,0 +1,672 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QtDeclarative/qdeclarativeengine.h>
+#include <QtDeclarative/qdeclarativecomponent.h>
+#include <QtDeclarative/qdeclarativeview.h>
+#include <private/qdeclarativerectangle_p.h>
+#include <private/qdeclarativeanimation_p.h>
+#include <QVariantAnimation>
+#include <QEasingCurve>
+
+class tst_qdeclarativeanimations : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qdeclarativeanimations() {}
+
+private slots:
+ void initTestCase() { QDeclarativeEngine engine; } // ensure types are registered
+
+ void simpleProperty();
+ void simpleNumber();
+ void simpleColor();
+ void alwaysRunToEnd();
+ void complete();
+ void resume();
+ void dotProperty();
+ void badTypes();
+ void badProperties();
+ void mixedTypes();
+ void properties();
+ void propertiesTransition();
+ void invalidDuration();
+ void attached();
+ void propertyValueSourceDefaultStart();
+ void dontStart();
+ void easingProperties();
+};
+
+#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()
+{
+ QDeclarativeRectangle rect;
+ QDeclarativePropertyAnimation animation;
+ animation.setTarget(&rect);
+ animation.setProperty("pos");
+ animation.setTo(QPointF(200,200));
+ QVERIFY(animation.target() == &rect);
+ QVERIFY(animation.property() == "pos");
+ QVERIFY(animation.to().toPointF() == QPointF(200,200));
+ animation.start();
+ QVERIFY(animation.isRunning());
+ QTest::qWait(animation.duration());
+ QTIMED_COMPARE(rect.pos(), QPointF(200,200));
+
+ rect.setPos(0,0);
+ animation.start();
+ animation.pause();
+ QVERIFY(animation.isRunning());
+ QVERIFY(animation.isPaused());
+ animation.setCurrentTime(125);
+ QVERIFY(animation.currentTime() == 125);
+ QCOMPARE(rect.pos(), QPointF(100,100));
+}
+
+void tst_qdeclarativeanimations::simpleNumber()
+{
+ QDeclarativeRectangle rect;
+ QDeclarativeNumberAnimation animation;
+ animation.setTarget(&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()
+{
+ QDeclarativeRectangle rect;
+ QDeclarativeColorAnimation animation;
+ animation.setTarget(&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);
+ 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::alwaysRunToEnd()
+{
+ QDeclarativeRectangle rect;
+ QDeclarativePropertyAnimation animation;
+ animation.setTarget(&rect);
+ animation.setProperty("x");
+ animation.setTo(200);
+ animation.setDuration(1000);
+ animation.setRepeat(true);
+ animation.setAlwaysRunToEnd(true);
+ QVERIFY(animation.repeat() == true);
+ 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()
+{
+ QDeclarativeRectangle rect;
+ QDeclarativePropertyAnimation animation;
+ animation.setTarget(&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()
+{
+ QDeclarativeRectangle rect;
+ QDeclarativePropertyAnimation animation;
+ animation.setTarget(&rect);
+ animation.setProperty("x");
+ animation.setFrom(10);
+ animation.setTo(200);
+ animation.setDuration(500);
+ QVERIFY(animation.from() == 10);
+
+ animation.start();
+ QTest::qWait(100);
+ animation.pause();
+ qreal x = rect.x();
+ QVERIFY(x != qreal(200));
+ QVERIFY(animation.isRunning());
+ QVERIFY(animation.isPaused());
+
+ animation.resume();
+ QVERIFY(animation.isRunning());
+ QVERIFY(!animation.isPaused());
+ QTest::qWait(100);
+ animation.stop();
+ QVERIFY(rect.x() > x);
+}
+
+void tst_qdeclarativeanimations::dotProperty()
+{
+ QDeclarativeRectangle rect;
+ QDeclarativeNumberAnimation animation;
+ animation.setTarget(&rect);
+ animation.setProperty("border.width");
+ animation.setTo(10);
+ animation.start();
+ QTest::qWait(animation.duration()+50);
+ QTIMED_COMPARE(rect.border()->width(), 10);
+
+ rect.border()->setWidth(0);
+ animation.start();
+ animation.pause();
+ animation.setCurrentTime(125);
+ QVERIFY(animation.currentTime() == 125);
+ QCOMPARE(rect.border()->width(), 5);
+}
+
+void tst_qdeclarativeanimations::badTypes()
+{
+ //don't crash
+ {
+ QDeclarativeView *view = new QDeclarativeView;
+ view->setSource(QUrl::fromLocalFile(SRCDIR "/data/badtype1.qml"));
+
+ qApp->processEvents();
+
+ delete view;
+ }
+
+ //make sure we get a compiler error
+ {
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/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: double expected"));
+ }
+
+ //make sure we get a compiler error
+ {
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/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, QUrl::fromLocalFile(SRCDIR "/data/badtype4.qml"));
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect);
+
+ rect->setState("state1");
+ QTest::qWait(1000 + 50);
+ QDeclarativeRectangle *myRect = rect->findChild<QDeclarativeRectangle*>("MyRect");
+ QVERIFY(myRect);
+ QCOMPARE(myRect->x(),qreal(200));
+ }
+}
+
+void tst_qdeclarativeanimations::badProperties()
+{
+ //make sure we get a runtime error
+ {
+ QDeclarativeEngine engine;
+
+ QDeclarativeComponent c1(&engine, QUrl::fromLocalFile(SRCDIR "/data/badproperty1.qml"));
+ QByteArray message = "QML ColorAnimation (" + QUrl::fromLocalFile(SRCDIR "/data/badproperty1.qml").toString().toUtf8() + ":18:9) Cannot animate non-existent property \"border.colr\"";
+ QTest::ignoreMessage(QtWarningMsg, message);
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c1.create());
+ QVERIFY(rect);
+
+ QDeclarativeComponent c2(&engine, QUrl::fromLocalFile(SRCDIR "/data/badproperty2.qml"));
+ message = "QML ColorAnimation (" + QUrl::fromLocalFile(SRCDIR "/data/badproperty2.qml").toString().toUtf8() + ":18:9) Cannot animate read-only property \"border\"";
+ QTest::ignoreMessage(QtWarningMsg, message);
+ rect = qobject_cast<QDeclarativeRectangle*>(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, QUrl::fromLocalFile(SRCDIR "/data/mixedtype1.qml"));
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect);
+
+ rect->setState("state1");
+ QTest::qWait(500);
+ QDeclarativeRectangle *myRect = rect->findChild<QDeclarativeRectangle*>("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, QUrl::fromLocalFile(SRCDIR "/data/mixedtype2.qml"));
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect);
+
+ rect->setState("state1");
+ QTest::qWait(500);
+ QDeclarativeRectangle *myRect = rect->findChild<QDeclarativeRectangle*>("MyRect");
+ QVERIFY(myRect);
+
+ //rather inexact -- is there a better way?
+ QVERIFY(myRect->x() > 100 && myRect->x() < 200);
+ QVERIFY(myRect->color() != QColor("red") && myRect->color() != QColor("blue"));
+ }
+}
+
+void tst_qdeclarativeanimations::properties()
+{
+ const int waitDuration = 300;
+ {
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/properties.qml"));
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QDeclarativeRectangle *myRect = rect->findChild<QDeclarativeRectangle*>("TheRect");
+ QVERIFY(myRect);
+ QTest::qWait(waitDuration);
+ QTIMED_COMPARE(myRect->x(),qreal(200));
+ }
+
+ {
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/properties2.qml"));
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QDeclarativeRectangle *myRect = rect->findChild<QDeclarativeRectangle*>("TheRect");
+ QVERIFY(myRect);
+ QTest::qWait(waitDuration);
+ QTIMED_COMPARE(myRect->x(),qreal(200));
+ }
+
+ {
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/properties3.qml"));
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QDeclarativeRectangle *myRect = rect->findChild<QDeclarativeRectangle*>("TheRect");
+ QVERIFY(myRect);
+ QTest::qWait(waitDuration);
+ QTIMED_COMPARE(myRect->x(),qreal(300));
+ }
+
+ {
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/properties4.qml"));
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QDeclarativeRectangle *myRect = rect->findChild<QDeclarativeRectangle*>("TheRect");
+ QVERIFY(myRect);
+ QTest::qWait(waitDuration);
+ QTIMED_COMPARE(myRect->y(),qreal(200));
+ QTIMED_COMPARE(myRect->x(),qreal(100));
+ }
+
+ {
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/properties5.qml"));
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QDeclarativeRectangle *myRect = rect->findChild<QDeclarativeRectangle*>("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, QUrl::fromLocalFile(SRCDIR "/data/propertiesTransition.qml"));
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect);
+
+ rect->setState("moved");
+ QDeclarativeRectangle *myRect = rect->findChild<QDeclarativeRectangle*>("TheRect");
+ QVERIFY(myRect);
+ QTest::qWait(waitDuration);
+ QTIMED_COMPARE(myRect->x(),qreal(200));
+ }
+
+ {
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertiesTransition2.qml"));
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QDeclarativeRectangle *myRect = rect->findChild<QDeclarativeRectangle*>("TheRect");
+ QVERIFY(myRect);
+ 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, QUrl::fromLocalFile(SRCDIR "/data/propertiesTransition3.qml"));
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QDeclarativeRectangle *myRect = rect->findChild<QDeclarativeRectangle*>("TheRect");
+ QVERIFY(myRect);
+ rect->setState("moved");
+ QCOMPARE(myRect->x(),qreal(200));
+ QCOMPARE(myRect->y(),qreal(100));
+ }
+
+ {
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertiesTransition4.qml"));
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QDeclarativeRectangle *myRect = rect->findChild<QDeclarativeRectangle*>("TheRect");
+ QVERIFY(myRect);
+ rect->setState("moved");
+ QCOMPARE(myRect->x(),qreal(100));
+ QTest::qWait(waitDuration);
+ QTIMED_COMPARE(myRect->x(),qreal(200));
+ }
+
+ {
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertiesTransition5.qml"));
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QDeclarativeRectangle *myRect = rect->findChild<QDeclarativeRectangle*>("TheRect");
+ QVERIFY(myRect);
+ rect->setState("moved");
+ QCOMPARE(myRect->x(),qreal(100));
+ QTest::qWait(waitDuration);
+ QTIMED_COMPARE(myRect->x(),qreal(200));
+ }
+
+ /*{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertiesTransition6.qml"));
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QDeclarativeRectangle *myRect = rect->findChild<QDeclarativeRectangle*>("TheRect");
+ QVERIFY(myRect);
+ rect->setState("moved");
+ QCOMPARE(myRect->x(),qreal(100));
+ QTest::qWait(waitDuration);
+ QTIMED_COMPARE(myRect->x(),qreal(100));
+ }*/
+}
+
+void tst_qdeclarativeanimations::invalidDuration()
+{
+ QDeclarativePropertyAnimation *animation = new QDeclarativePropertyAnimation;
+ QTest::ignoreMessage(QtWarningMsg, "QML PropertyAnimation (unknown location) Cannot set a duration of < 0");
+ animation->setDuration(-1);
+ QCOMPARE(animation->duration(), 250);
+
+ QDeclarativePauseAnimation *pauseAnimation = new QDeclarativePauseAnimation;
+ QTest::ignoreMessage(QtWarningMsg, "QML PauseAnimation (unknown location) Cannot set a duration of < 0");
+ pauseAnimation->setDuration(-1);
+ QCOMPARE(pauseAnimation->duration(), 250);
+}
+
+void tst_qdeclarativeanimations::attached()
+{
+ QDeclarativeEngine engine;
+
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/attached.qml"));
+ QTest::ignoreMessage(QtDebugMsg, "off");
+ QTest::ignoreMessage(QtDebugMsg, "on");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect);
+}
+
+void tst_qdeclarativeanimations::propertyValueSourceDefaultStart()
+{
+ {
+ QDeclarativeEngine engine;
+
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/valuesource.qml"));
+
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QDeclarativeAbstractAnimation *myAnim = rect->findChild<QDeclarativeAbstractAnimation*>("MyAnim");
+ QVERIFY(myAnim);
+ QVERIFY(myAnim->isRunning());
+ }
+
+ {
+ QDeclarativeEngine engine;
+
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/valuesource2.qml"));
+
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QDeclarativeAbstractAnimation *myAnim = rect->findChild<QDeclarativeAbstractAnimation*>("MyAnim");
+ QVERIFY(myAnim);
+ QVERIFY(myAnim->isRunning() == false);
+ }
+
+ {
+ QDeclarativeEngine engine;
+
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/dontAutoStart.qml"));
+
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QDeclarativeAbstractAnimation *myAnim = rect->findChild<QDeclarativeAbstractAnimation*>("MyAnim");
+ QVERIFY(myAnim && myAnim->qtAnimation());
+ QVERIFY(myAnim->qtAnimation()->state() == QAbstractAnimation::Stopped);
+ }
+}
+
+
+void tst_qdeclarativeanimations::dontStart()
+{
+ {
+ QDeclarativeEngine engine;
+
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/dontStart.qml"));
+
+ QTest::ignoreMessage(QtWarningMsg, "QDeclarativeAbstractAnimation: setRunning() cannot be used on non-root animation nodes");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QDeclarativeAbstractAnimation *myAnim = rect->findChild<QDeclarativeAbstractAnimation*>("MyAnim");
+ QVERIFY(myAnim && myAnim->qtAnimation());
+ QVERIFY(myAnim->qtAnimation()->state() == QAbstractAnimation::Stopped);
+ }
+
+ {
+ QDeclarativeEngine engine;
+
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/dontStart2.qml"));
+
+ QTest::ignoreMessage(QtWarningMsg, "QDeclarativeAbstractAnimation: setRunning() cannot be used on non-root animation nodes");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QDeclarativeAbstractAnimation *myAnim = rect->findChild<QDeclarativeAbstractAnimation*>("MyAnim");
+ QVERIFY(myAnim && myAnim->qtAnimation());
+ QVERIFY(myAnim->qtAnimation()->state() == QAbstractAnimation::Stopped);
+ }
+}
+
+void tst_qdeclarativeanimations::easingProperties()
+{
+ {
+ QDeclarativeEngine engine;
+ QString componentStr = "import Qt 4.6\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 Qt 4.6\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 Qt 4.6\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 Qt 4.6\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);
+ }
+}
+
+QTEST_MAIN(tst_qdeclarativeanimations)
+
+#include "tst_qdeclarativeanimations.moc"
diff --git a/tests/auto/declarative/qmlbehaviors/data/binding.qml b/tests/auto/declarative/qdeclarativebehaviors/data/binding.qml
index 201da37..201da37 100644
--- a/tests/auto/declarative/qmlbehaviors/data/binding.qml
+++ b/tests/auto/declarative/qdeclarativebehaviors/data/binding.qml
diff --git a/tests/auto/declarative/qmlbehaviors/data/color.qml b/tests/auto/declarative/qdeclarativebehaviors/data/color.qml
index 91dbbd1..91dbbd1 100644
--- a/tests/auto/declarative/qmlbehaviors/data/color.qml
+++ b/tests/auto/declarative/qdeclarativebehaviors/data/color.qml
diff --git a/tests/auto/declarative/qmlbehaviors/data/cpptrigger.qml b/tests/auto/declarative/qdeclarativebehaviors/data/cpptrigger.qml
index 8d032f0..8d032f0 100644
--- a/tests/auto/declarative/qmlbehaviors/data/cpptrigger.qml
+++ b/tests/auto/declarative/qdeclarativebehaviors/data/cpptrigger.qml
diff --git a/tests/auto/declarative/qmlbehaviors/data/disabled.qml b/tests/auto/declarative/qdeclarativebehaviors/data/disabled.qml
index 3c7078a..3c7078a 100644
--- a/tests/auto/declarative/qmlbehaviors/data/disabled.qml
+++ b/tests/auto/declarative/qdeclarativebehaviors/data/disabled.qml
diff --git a/tests/auto/declarative/qmlbehaviors/data/dontStart.qml b/tests/auto/declarative/qdeclarativebehaviors/data/dontStart.qml
index ba7cc9c..ba7cc9c 100644
--- a/tests/auto/declarative/qmlbehaviors/data/dontStart.qml
+++ b/tests/auto/declarative/qdeclarativebehaviors/data/dontStart.qml
diff --git a/tests/auto/declarative/qmlbehaviors/data/empty.qml b/tests/auto/declarative/qdeclarativebehaviors/data/empty.qml
index 95d934a..95d934a 100644
--- a/tests/auto/declarative/qmlbehaviors/data/empty.qml
+++ b/tests/auto/declarative/qdeclarativebehaviors/data/empty.qml
diff --git a/tests/auto/declarative/qmlbehaviors/data/explicit.qml b/tests/auto/declarative/qdeclarativebehaviors/data/explicit.qml
index 1b2025a..1b2025a 100644
--- a/tests/auto/declarative/qmlbehaviors/data/explicit.qml
+++ b/tests/auto/declarative/qdeclarativebehaviors/data/explicit.qml
diff --git a/tests/auto/declarative/qmlbehaviors/data/groupProperty.qml b/tests/auto/declarative/qdeclarativebehaviors/data/groupProperty.qml
index 14883d4..14883d4 100644
--- a/tests/auto/declarative/qmlbehaviors/data/groupProperty.qml
+++ b/tests/auto/declarative/qdeclarativebehaviors/data/groupProperty.qml
diff --git a/tests/auto/declarative/qmlbehaviors/data/groupProperty2.qml b/tests/auto/declarative/qdeclarativebehaviors/data/groupProperty2.qml
index b43ddbc..b43ddbc 100644
--- a/tests/auto/declarative/qmlbehaviors/data/groupProperty2.qml
+++ b/tests/auto/declarative/qdeclarativebehaviors/data/groupProperty2.qml
diff --git a/tests/auto/declarative/qmlbehaviors/data/loop.qml b/tests/auto/declarative/qdeclarativebehaviors/data/loop.qml
index 5f2c057..5f2c057 100644
--- a/tests/auto/declarative/qmlbehaviors/data/loop.qml
+++ b/tests/auto/declarative/qdeclarativebehaviors/data/loop.qml
diff --git a/tests/auto/declarative/qmlbehaviors/data/nonSelecting2.qml b/tests/auto/declarative/qdeclarativebehaviors/data/nonSelecting2.qml
index f267a05..f267a05 100644
--- a/tests/auto/declarative/qmlbehaviors/data/nonSelecting2.qml
+++ b/tests/auto/declarative/qdeclarativebehaviors/data/nonSelecting2.qml
diff --git a/tests/auto/declarative/qmlbehaviors/data/parent.qml b/tests/auto/declarative/qdeclarativebehaviors/data/parent.qml
index 7c7fdcb..7c7fdcb 100644
--- a/tests/auto/declarative/qmlbehaviors/data/parent.qml
+++ b/tests/auto/declarative/qdeclarativebehaviors/data/parent.qml
diff --git a/tests/auto/declarative/qmlbehaviors/data/reassignedAnimation.qml b/tests/auto/declarative/qdeclarativebehaviors/data/reassignedAnimation.qml
index ba744b1..ba744b1 100644
--- a/tests/auto/declarative/qmlbehaviors/data/reassignedAnimation.qml
+++ b/tests/auto/declarative/qdeclarativebehaviors/data/reassignedAnimation.qml
diff --git a/tests/auto/declarative/qmlbehaviors/data/scripttrigger.qml b/tests/auto/declarative/qdeclarativebehaviors/data/scripttrigger.qml
index a91ca88..a91ca88 100644
--- a/tests/auto/declarative/qmlbehaviors/data/scripttrigger.qml
+++ b/tests/auto/declarative/qdeclarativebehaviors/data/scripttrigger.qml
diff --git a/tests/auto/declarative/qmlbehaviors/data/simple.qml b/tests/auto/declarative/qdeclarativebehaviors/data/simple.qml
index ac98ed0..ac98ed0 100644
--- a/tests/auto/declarative/qmlbehaviors/data/simple.qml
+++ b/tests/auto/declarative/qdeclarativebehaviors/data/simple.qml
diff --git a/tests/auto/declarative/qdeclarativebehaviors/qdeclarativebehaviors.pro b/tests/auto/declarative/qdeclarativebehaviors/qdeclarativebehaviors.pro
new file mode 100644
index 0000000..a1dac32
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativebehaviors/qdeclarativebehaviors.pro
@@ -0,0 +1,6 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative
+SOURCES += tst_qdeclarativebehaviors.cpp
+macx:CONFIG -= app_bundle
+
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp b/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp
new file mode 100644
index 0000000..f87330d
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp
@@ -0,0 +1,301 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QtDeclarative/qdeclarativeengine.h>
+#include <QtDeclarative/qdeclarativecomponent.h>
+#include <QtDeclarative/qdeclarativeview.h>
+#include <private/qdeclarativerectangle_p.h>
+#include <private/qdeclarativebehavior_p.h>
+#include <private/qdeclarativeanimation_p.h>
+
+class tst_qdeclarativebehaviors : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qdeclarativebehaviors() {}
+
+private slots:
+ void simpleBehavior();
+ void scriptTriggered();
+ void cppTriggered();
+ void loop();
+ void colorBehavior();
+ void parentBehavior();
+ void replaceBinding();
+ //void transitionOverrides();
+ void group();
+ void emptyBehavior();
+ void explicitSelection();
+ void nonSelectingBehavior();
+ void reassignedAnimation();
+ void disabled();
+ void dontStart();
+};
+
+void tst_qdeclarativebehaviors::simpleBehavior()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/simple.qml"));
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect);
+ QVERIFY(qobject_cast<QDeclarativeBehavior*>(rect->findChild<QDeclarativeBehavior*>("MyBehavior"))->animation());
+
+ rect->setState("moved");
+ QTest::qWait(200);
+ qreal x = qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"))->x();
+ QVERIFY(x > 0 && x < 200); //i.e. the behavior has been triggered
+}
+
+void tst_qdeclarativebehaviors::scriptTriggered()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/scripttrigger.qml"));
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect);
+
+ rect->setColor(QColor("red"));
+ QTest::qWait(200);
+ qreal x = qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"))->x();
+ QVERIFY(x > 0 && x < 200); //i.e. the behavior has been triggered
+}
+
+void tst_qdeclarativebehaviors::cppTriggered()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/cpptrigger.qml"));
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QDeclarativeRectangle *innerRect = qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"));
+ QVERIFY(innerRect);
+
+ innerRect->setProperty("x", 200);
+ QTest::qWait(200);
+ qreal x = innerRect->x();
+ QVERIFY(x > 0 && x < 200); //i.e. the behavior has been triggered
+}
+
+void tst_qdeclarativebehaviors::loop()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/loop.qml"));
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect);
+
+ //don't crash
+ rect->setState("moved");
+}
+
+void tst_qdeclarativebehaviors::colorBehavior()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/color.qml"));
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect);
+
+ rect->setState("red");
+ QTest::qWait(200);
+ QColor color = qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"))->color();
+ QVERIFY(color != QColor("red") && color != QColor("green")); //i.e. the behavior has been triggered
+}
+
+void tst_qdeclarativebehaviors::parentBehavior()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/parent.qml"));
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect);
+
+ rect->setState("reparented");
+ QTest::qWait(200);
+ QDeclarativeItem *newParent = rect->findChild<QDeclarativeItem*>("NewParent");
+ QDeclarativeItem *parent = rect->findChild<QDeclarativeRectangle*>("MyRect")->parentItem();
+ QVERIFY(parent != newParent);
+ QTest::qWait(600);
+ parent = rect->findChild<QDeclarativeRectangle*>("MyRect")->parentItem();
+ QVERIFY(parent == newParent);
+}
+
+void tst_qdeclarativebehaviors::replaceBinding()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/binding.qml"));
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect);
+
+ rect->setState("moved");
+ QTest::qWait(200);
+ QDeclarativeRectangle *innerRect = qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"));
+ QVERIFY(innerRect);
+ qreal x = innerRect->x();
+ QVERIFY(x > 0 && x < 200); //i.e. the behavior has been triggered
+ QTest::qWait(600);
+ QCOMPARE(innerRect->x(), (qreal)200);
+ rect->setProperty("basex", 10);
+ QCOMPARE(innerRect->x(), (qreal)200);
+ rect->setProperty("movedx", 210);
+ QTest::qWait(600);
+ QCOMPARE(innerRect->x(), (qreal)210);
+
+ rect->setState("");
+ QTest::qWait(200);
+ x = innerRect->x();
+ QVERIFY(x > 10 && x < 210); //i.e. the behavior has been triggered
+ QTest::qWait(600);
+ QCOMPARE(innerRect->x(), (qreal)10);
+ rect->setProperty("movedx", 200);
+ QCOMPARE(innerRect->x(), (qreal)10);
+ rect->setProperty("basex", 20);
+ QTest::qWait(600);
+ QCOMPARE(innerRect->x(), (qreal)20);
+}
+
+void tst_qdeclarativebehaviors::group()
+{
+ {
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/groupProperty.qml"));
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect);
+
+ rect->setState("moved");
+ QTest::qWait(200);
+ qreal x = qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"))->x();
+ QVERIFY(x > 0 && x < 200); //i.e. the behavior has been triggered
+ }
+
+ {
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/groupProperty2.qml"));
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect);
+
+ rect->setState("moved");
+ QTest::qWait(200);
+ qreal x = qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"))->x();
+ QVERIFY(x > 0 && x < 200); //i.e. the behavior has been triggered
+ }
+}
+
+void tst_qdeclarativebehaviors::emptyBehavior()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/empty.qml"));
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect);
+
+ rect->setState("moved");
+ qreal x = qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"))->x();
+ QCOMPARE(x, qreal(200)); //should change immediately
+}
+
+void tst_qdeclarativebehaviors::explicitSelection()
+{
+ {
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/explicit.qml"));
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect);
+
+ rect->setState("moved");
+ QTest::qWait(200);
+ qreal x = qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"))->x();
+ QVERIFY(x > 0 && x < 200); //i.e. the behavior has been triggered
+ }
+}
+
+void tst_qdeclarativebehaviors::nonSelectingBehavior()
+{
+ {
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/nonSelecting2.qml"));
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect);
+
+ rect->setState("moved");
+ qreal x = qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"))->x();
+ QCOMPARE(x, qreal(200)); //should change immediately
+ }
+}
+
+void tst_qdeclarativebehaviors::reassignedAnimation()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/reassignedAnimation.qml"));
+ QTest::ignoreMessage(QtWarningMsg, QString("QML Behavior (" + QUrl::fromLocalFile(SRCDIR "/data/reassignedAnimation.qml").toString() + ":9:12) Cannot change the animation assigned to a Behavior.").toUtf8().constData());
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect);
+ QCOMPARE(qobject_cast<QDeclarativeNumberAnimation*>(
+ qobject_cast<QDeclarativeBehavior*>(
+ rect->findChild<QDeclarativeBehavior*>("MyBehavior"))->animation())->duration(), 200);
+}
+
+void tst_qdeclarativebehaviors::disabled()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/disabled.qml"));
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect);
+ QCOMPARE(rect->findChild<QDeclarativeBehavior*>("MyBehavior")->enabled(), false);
+
+ rect->setState("moved");
+ qreal x = qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"))->x();
+ QCOMPARE(x, qreal(200)); //should change immediately
+}
+
+void tst_qdeclarativebehaviors::dontStart()
+{
+ QDeclarativeEngine engine;
+
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/dontStart.qml"));
+
+ QTest::ignoreMessage(QtWarningMsg, "QDeclarativeAbstractAnimation: setRunning() cannot be used on non-root animation nodes");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QDeclarativeAbstractAnimation *myAnim = rect->findChild<QDeclarativeAbstractAnimation*>("MyAnim");
+ QVERIFY(myAnim && myAnim->qtAnimation());
+ QVERIFY(myAnim->qtAnimation()->state() == QAbstractAnimation::Stopped);
+}
+
+QTEST_MAIN(tst_qdeclarativebehaviors)
+
+#include "tst_qdeclarativebehaviors.moc"
diff --git a/tests/auto/declarative/qmlbinding/data/test-binding.qml b/tests/auto/declarative/qdeclarativebinding/data/test-binding.qml
index e9101e4..e9101e4 100644
--- a/tests/auto/declarative/qmlbinding/data/test-binding.qml
+++ b/tests/auto/declarative/qdeclarativebinding/data/test-binding.qml
diff --git a/tests/auto/declarative/qmlbinding/data/test-binding2.qml b/tests/auto/declarative/qdeclarativebinding/data/test-binding2.qml
index ea20c16..ea20c16 100644
--- a/tests/auto/declarative/qmlbinding/data/test-binding2.qml
+++ b/tests/auto/declarative/qdeclarativebinding/data/test-binding2.qml
diff --git a/tests/auto/declarative/qdeclarativebinding/qdeclarativebinding.pro b/tests/auto/declarative/qdeclarativebinding/qdeclarativebinding.pro
new file mode 100644
index 0000000..7879976
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativebinding/qdeclarativebinding.pro
@@ -0,0 +1,8 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative gui
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qdeclarativebinding.cpp
+
+# Define SRCDIR equal to test's source directory
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qdeclarativebinding/tst_qdeclarativebinding.cpp b/tests/auto/declarative/qdeclarativebinding/tst_qdeclarativebinding.cpp
new file mode 100644
index 0000000..826df4f
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativebinding/tst_qdeclarativebinding.cpp
@@ -0,0 +1,107 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QtDeclarative/qdeclarativeengine.h>
+#include <QtDeclarative/qdeclarativecomponent.h>
+#include <private/qdeclarativebind_p.h>
+#include <private/qdeclarativerectangle_p.h>
+#include "../../../shared/util.h"
+
+class tst_qdeclarativebinding : public QObject
+
+{
+ Q_OBJECT
+public:
+ tst_qdeclarativebinding();
+
+private slots:
+ void binding();
+ void whenAfterValue();
+
+private:
+ QDeclarativeEngine engine;
+};
+
+tst_qdeclarativebinding::tst_qdeclarativebinding()
+{
+}
+
+void tst_qdeclarativebinding::binding()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/test-binding.qml"));
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(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"));
+
+ QDeclarativeBind *binding = qobject_cast<QDeclarativeBind*>(rect->findChild<QDeclarativeBind*>("binding1"));
+ QVERIFY(binding != 0);
+ QCOMPARE(binding->object(), rect);
+ QCOMPARE(binding->property(), QLatin1String("text"));
+ QCOMPARE(binding->value().toString(), QLatin1String("Hello"));
+
+ delete rect;
+}
+
+void tst_qdeclarativebinding::whenAfterValue()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/test-binding2.qml"));
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(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;
+}
+
+QTEST_MAIN(tst_qdeclarativebinding)
+
+#include "tst_qdeclarativebinding.moc"
diff --git a/tests/auto/declarative/qmlgraphicsborderimage/data/colors-round.sci b/tests/auto/declarative/qdeclarativeborderimage/data/colors-round.sci
index 5d2f49f..5d2f49f 100644
--- a/tests/auto/declarative/qmlgraphicsborderimage/data/colors-round.sci
+++ b/tests/auto/declarative/qdeclarativeborderimage/data/colors-round.sci
diff --git a/tests/auto/declarative/visual/qmlgraphicsborderimage/content/colors.png b/tests/auto/declarative/qdeclarativeborderimage/data/colors.png
index dfb62f3..dfb62f3 100644
--- a/tests/auto/declarative/visual/qmlgraphicsborderimage/content/colors.png
+++ b/tests/auto/declarative/qdeclarativeborderimage/data/colors.png
Binary files differ
diff --git a/tests/auto/declarative/qmlgraphicsborderimage/data/invalid.sci b/tests/auto/declarative/qdeclarativeborderimage/data/invalid.sci
index 98c72c9..98c72c9 100644
--- a/tests/auto/declarative/qmlgraphicsborderimage/data/invalid.sci
+++ b/tests/auto/declarative/qdeclarativeborderimage/data/invalid.sci
diff --git a/tests/auto/declarative/qdeclarativeborderimage/qdeclarativeborderimage.pro b/tests/auto/declarative/qdeclarativeborderimage/qdeclarativeborderimage.pro
new file mode 100644
index 0000000..0574ddb
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeborderimage/qdeclarativeborderimage.pro
@@ -0,0 +1,9 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative gui network
+macx:CONFIG -= app_bundle
+
+HEADERS += ../shared/testhttpserver.h
+SOURCES += tst_qdeclarativeborderimage.cpp ../shared/testhttpserver.cpp
+
+# Define SRCDIR equal to test's source directory
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp b/tests/auto/declarative/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp
new file mode 100644
index 0000000..8aeba6d
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp
@@ -0,0 +1,351 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QTextDocument>
+#include <QTcpServer>
+#include <QTcpSocket>
+#include <QDir>
+
+#include <QtDeclarative/qdeclarativeengine.h>
+#include <QtDeclarative/qdeclarativecomponent.h>
+#include <private/qdeclarativeborderimage_p.h>
+#include <private/qdeclarativeimagebase_p.h>
+#include <private/qdeclarativescalegrid_p_p.h>
+#include <private/qdeclarativeloader_p.h>
+#include <QtDeclarative/qdeclarativecontext.h>
+
+#include "../shared/testhttpserver.h"
+
+
+#define SERVER_PORT 14445
+#define SERVER_ADDR "http://127.0.0.1:14445"
+
+#define TRY_WAIT(expr) \
+ do { \
+ for (int ii = 0; ii < 60; ++ii) { \
+ if ((expr)) break; \
+ QTest::qWait(50); \
+ } \
+ QVERIFY((expr)); \
+ } while (false)
+
+
+class tst_qdeclarativeborderimage : public QObject
+
+{
+ Q_OBJECT
+public:
+ tst_qdeclarativeborderimage();
+
+private slots:
+ void noSource();
+ void imageSource();
+ void imageSource_data();
+ void clearSource();
+ void resized();
+ void smooth();
+ void tileModes();
+ void sciSource();
+ void sciSource_data();
+ void invalidSciFile();
+ void pendingRemoteRequest();
+ void pendingRemoteRequest_data();
+
+private:
+ QDeclarativeEngine engine;
+};
+
+tst_qdeclarativeborderimage::tst_qdeclarativeborderimage()
+{
+}
+
+void tst_qdeclarativeborderimage::noSource()
+{
+ QString componentStr = "import Qt 4.6\nBorderImage { source: \"\" }";
+ QDeclarativeComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeBorderImage *obj = qobject_cast<QDeclarativeBorderImage*>(component.create());
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->source(), QUrl());
+ QCOMPARE(obj->width(), 0.);
+ QCOMPARE(obj->height(), 0.);
+ QCOMPARE(obj->horizontalTileMode(), QDeclarativeBorderImage::Stretch);
+ QCOMPARE(obj->verticalTileMode(), QDeclarativeBorderImage::Stretch);
+
+ delete obj;
+}
+
+void tst_qdeclarativeborderimage::imageSource_data()
+{
+ QTest::addColumn<QString>("source");
+ QTest::addColumn<bool>("remote");
+ QTest::addColumn<QString>("error");
+
+ QTest::newRow("local") << QUrl::fromLocalFile(SRCDIR "/data/colors.png").toString() << false << "";
+ QTest::newRow("local not found") << QUrl::fromLocalFile(SRCDIR "/data/no-such-file.png").toString() << false
+ << "Cannot open QUrl( \"" + QUrl::fromLocalFile(SRCDIR "/data/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
+ << "\"Error downloading " SERVER_ADDR "/no-such-file.png - server replied: Not found\" ";
+}
+
+void tst_qdeclarativeborderimage::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(SRCDIR "/data");
+ }
+
+ if (!error.isEmpty())
+ QTest::ignoreMessage(QtWarningMsg, error.toUtf8());
+
+ QString componentStr = "import Qt 4.6\nBorderImage { source: \"" + source + "\" }";
+ QDeclarativeComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeBorderImage *obj = qobject_cast<QDeclarativeBorderImage*>(component.create());
+ QVERIFY(obj != 0);
+
+ if (remote)
+ TRY_WAIT(obj->status() == QDeclarativeBorderImage::Loading);
+
+ QCOMPARE(obj->source(), remote ? source : QUrl(source));
+
+ if (error.isEmpty()) {
+ TRY_WAIT(obj->status() == QDeclarativeBorderImage::Ready);
+ QCOMPARE(obj->width(), 120.);
+ QCOMPARE(obj->height(), 120.);
+ QCOMPARE(obj->horizontalTileMode(), QDeclarativeBorderImage::Stretch);
+ QCOMPARE(obj->verticalTileMode(), QDeclarativeBorderImage::Stretch);
+ } else {
+ TRY_WAIT(obj->status() == QDeclarativeBorderImage::Error);
+ }
+
+ delete obj;
+ delete server;
+}
+
+void tst_qdeclarativeborderimage::clearSource()
+{
+ QString componentStr = "import Qt 4.6\nBorderImage { source: srcImage }";
+ QDeclarativeContext *ctxt = engine.rootContext();
+ ctxt->setContextProperty("srcImage", QUrl::fromLocalFile(SRCDIR "/data/colors.png"));
+ QDeclarativeComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeBorderImage *obj = qobject_cast<QDeclarativeBorderImage*>(component.create());
+ QVERIFY(obj != 0);
+ QVERIFY(obj->status() == QDeclarativeBorderImage::Ready);
+ QCOMPARE(obj->width(), 120.);
+ QCOMPARE(obj->height(), 120.);
+
+ ctxt->setContextProperty("srcImage", "");
+ QVERIFY(obj->source().isEmpty());
+ QVERIFY(obj->status() == QDeclarativeBorderImage::Null);
+ QCOMPARE(obj->width(), 0.);
+ QCOMPARE(obj->height(), 0.);
+}
+
+void tst_qdeclarativeborderimage::resized()
+{
+ QString componentStr = "import Qt 4.6\nBorderImage { source: \"" + QUrl::fromLocalFile(SRCDIR "/data/colors.png").toString() + "\"; width: 300; height: 300 }";
+ QDeclarativeComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeBorderImage *obj = qobject_cast<QDeclarativeBorderImage*>(component.create());
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->width(), 300.);
+ QCOMPARE(obj->height(), 300.);
+ QCOMPARE(obj->horizontalTileMode(), QDeclarativeBorderImage::Stretch);
+ QCOMPARE(obj->verticalTileMode(), QDeclarativeBorderImage::Stretch);
+
+ delete obj;
+}
+
+void tst_qdeclarativeborderimage::smooth()
+{
+ QString componentStr = "import Qt 4.6\nBorderImage { source: \"" SRCDIR "/data/colors.png\"; smooth: true; width: 300; height: 300 }";
+ QDeclarativeComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeBorderImage *obj = qobject_cast<QDeclarativeBorderImage*>(component.create());
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->width(), 300.);
+ QCOMPARE(obj->height(), 300.);
+ QCOMPARE(obj->smooth(), true);
+ QCOMPARE(obj->horizontalTileMode(), QDeclarativeBorderImage::Stretch);
+ QCOMPARE(obj->verticalTileMode(), QDeclarativeBorderImage::Stretch);
+
+ delete obj;
+}
+
+void tst_qdeclarativeborderimage::tileModes()
+{
+ {
+ QString componentStr = "import Qt 4.6\nBorderImage { source: \"" SRCDIR "/data/colors.png\"; width: 100; height: 300; horizontalTileMode: BorderImage.Repeat; verticalTileMode: BorderImage.Repeat }";
+ QDeclarativeComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeBorderImage *obj = qobject_cast<QDeclarativeBorderImage*>(component.create());
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->width(), 100.);
+ QCOMPARE(obj->height(), 300.);
+ QCOMPARE(obj->horizontalTileMode(), QDeclarativeBorderImage::Repeat);
+ QCOMPARE(obj->verticalTileMode(), QDeclarativeBorderImage::Repeat);
+
+ delete obj;
+ }
+ {
+ QString componentStr = "import Qt 4.6\nBorderImage { source: \"" SRCDIR "/data/colors.png\"; width: 300; height: 150; horizontalTileMode: BorderImage.Round; verticalTileMode: BorderImage.Round }";
+ QDeclarativeComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeBorderImage *obj = qobject_cast<QDeclarativeBorderImage*>(component.create());
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->width(), 300.);
+ QCOMPARE(obj->height(), 150.);
+ QCOMPARE(obj->horizontalTileMode(), QDeclarativeBorderImage::Round);
+ QCOMPARE(obj->verticalTileMode(), QDeclarativeBorderImage::Round);
+
+ delete obj;
+ }
+}
+
+void tst_qdeclarativeborderimage::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(SRCDIR "/data");
+ }
+
+ QString componentStr = "import Qt 4.6\nBorderImage { source: \"" + source + "\"; width: 300; height: 300 }";
+ QDeclarativeComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeBorderImage *obj = qobject_cast<QDeclarativeBorderImage*>(component.create());
+ QVERIFY(obj != 0);
+
+ if (remote)
+ TRY_WAIT(obj->status() == QDeclarativeBorderImage::Loading);
+
+ QCOMPARE(obj->source(), remote ? source : QUrl(source));
+ QCOMPARE(obj->width(), 300.);
+ QCOMPARE(obj->height(), 300.);
+
+ if (valid) {
+ TRY_WAIT(obj->status() == QDeclarativeBorderImage::Ready);
+ QCOMPARE(obj->border()->left(), 10);
+ QCOMPARE(obj->border()->top(), 20);
+ QCOMPARE(obj->border()->right(), 30);
+ QCOMPARE(obj->border()->bottom(), 40);
+ QCOMPARE(obj->horizontalTileMode(), QDeclarativeBorderImage::Round);
+ QCOMPARE(obj->verticalTileMode(), QDeclarativeBorderImage::Repeat);
+ } else {
+ TRY_WAIT(obj->status() == QDeclarativeBorderImage::Error);
+ }
+
+ delete obj;
+ delete server;
+}
+
+void tst_qdeclarativeborderimage::sciSource_data()
+{
+ QTest::addColumn<QString>("source");
+ QTest::addColumn<bool>("valid");
+
+ QTest::newRow("local") << QUrl::fromLocalFile(SRCDIR "/data/colors-round.sci").toString() << true;
+ QTest::newRow("local not found") << QUrl::fromLocalFile(SRCDIR "/data/no-such-file.sci").toString() << false;
+ QTest::newRow("remote") << SERVER_ADDR "/colors-round.sci" << true;
+ QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.sci" << false;
+}
+
+void tst_qdeclarativeborderimage::invalidSciFile()
+{
+ QTest::ignoreMessage(QtWarningMsg, "Unknown tile rule specified. Using Stretch "); // for "Roun"
+ QTest::ignoreMessage(QtWarningMsg, "Unknown tile rule specified. Using Stretch "); // for "Repea"
+
+ QString componentStr = "import Qt 4.6\nBorderImage { source: \"" + QUrl::fromLocalFile(SRCDIR "/data/invalid.sci").toString() +"\"; width: 300; height: 300 }";
+ QDeclarativeComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeBorderImage *obj = qobject_cast<QDeclarativeBorderImage*>(component.create());
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->width(), 300.);
+ QCOMPARE(obj->height(), 300.);
+ QCOMPARE(obj->status(), QDeclarativeImageBase::Error);
+ QCOMPARE(obj->horizontalTileMode(), QDeclarativeBorderImage::Stretch);
+ QCOMPARE(obj->verticalTileMode(), QDeclarativeBorderImage::Stretch);
+
+ delete obj;
+}
+
+void tst_qdeclarativeborderimage::pendingRemoteRequest()
+{
+ QFETCH(QString, source);
+
+ QString componentStr = "import Qt 4.6\nBorderImage { source: \"" + source + "\" }";
+ QDeclarativeComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeBorderImage *obj = qobject_cast<QDeclarativeBorderImage*>(component.create());
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->status(), QDeclarativeBorderImage::Loading);
+
+ // verify no crash
+ // This will cause a delayed "QThread: Destroyed while thread is still running" warning
+ delete obj;
+ QTest::qWait(50);
+}
+
+void tst_qdeclarativeborderimage::pendingRemoteRequest_data()
+{
+ QTest::addColumn<QString>("source");
+
+ QTest::newRow("png file") << "http://no-such-qt-server-like-this/none.png";
+ QTest::newRow("sci file") << "http://no-such-qt-server-like-this/none.sci";
+}
+
+QTEST_MAIN(tst_qdeclarativeborderimage)
+
+#include "tst_qdeclarativeborderimage.moc"
diff --git a/tests/auto/declarative/qdeclarativeconnection/data/test-connection.qml b/tests/auto/declarative/qdeclarativeconnection/data/test-connection.qml
new file mode 100644
index 0000000..81ab599
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeconnection/data/test-connection.qml
@@ -0,0 +1,10 @@
+import Qt 4.6
+
+Item {
+ id: screen; width: 50
+
+ property bool tested: false
+ signal testMe
+
+ Connections { target: screen; onWidthChanged: screen.tested = true }
+}
diff --git a/tests/auto/declarative/qdeclarativeconnection/data/test-connection2.qml b/tests/auto/declarative/qdeclarativeconnection/data/test-connection2.qml
new file mode 100644
index 0000000..22e9422
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeconnection/data/test-connection2.qml
@@ -0,0 +1,3 @@
+import Qt 4.6
+
+Connections { id: connection; target: connection; onTargetChanged: 1 == 1 }
diff --git a/tests/auto/declarative/qdeclarativeconnection/data/test-connection3.qml b/tests/auto/declarative/qdeclarativeconnection/data/test-connection3.qml
new file mode 100644
index 0000000..6e396c0
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeconnection/data/test-connection3.qml
@@ -0,0 +1,3 @@
+import Qt 4.6
+
+Connections {}
diff --git a/tests/auto/declarative/qdeclarativeconnection/data/trimming.qml b/tests/auto/declarative/qdeclarativeconnection/data/trimming.qml
new file mode 100644
index 0000000..736d5e8
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeconnection/data/trimming.qml
@@ -0,0 +1,10 @@
+import Qt 4.6
+
+Item {
+ id: screen; width: 50
+
+ property string tested
+ signal testMe(int param1, string param2)
+
+ Connections { target: screen; onTestMe: screen.tested = param2 + param1 }
+}
diff --git a/tests/auto/declarative/qdeclarativeconnection/qdeclarativeconnection.pro b/tests/auto/declarative/qdeclarativeconnection/qdeclarativeconnection.pro
new file mode 100644
index 0000000..a6adfa4
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeconnection/qdeclarativeconnection.pro
@@ -0,0 +1,8 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative gui
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qdeclarativeconnection.cpp
+
+# Define SRCDIR equal to test's source directory
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qdeclarativeconnection/tst_qdeclarativeconnection.cpp b/tests/auto/declarative/qdeclarativeconnection/tst_qdeclarativeconnection.cpp
new file mode 100644
index 0000000..f4914e1
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeconnection/tst_qdeclarativeconnection.cpp
@@ -0,0 +1,135 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QtDeclarative/qdeclarativeengine.h>
+#include <QtDeclarative/qdeclarativecomponent.h>
+#include <private/qdeclarativeconnections_p.h>
+#include <private/qdeclarativeitem_p.h>
+#include "../../../shared/util.h"
+#include <QtDeclarative/qdeclarativescriptstring.h>
+
+class tst_qdeclarativeconnection : public QObject
+
+{
+ Q_OBJECT
+public:
+ tst_qdeclarativeconnection();
+
+private slots:
+ void defaultValues();
+ void properties();
+ void connection();
+ void trimming();
+
+private:
+ QDeclarativeEngine engine;
+};
+
+tst_qdeclarativeconnection::tst_qdeclarativeconnection()
+{
+}
+
+void tst_qdeclarativeconnection::defaultValues()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/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, QUrl::fromLocalFile(SRCDIR "/data/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, QUrl::fromLocalFile(SRCDIR "/data/test-connection.qml"));
+ QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(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, QUrl::fromLocalFile(SRCDIR "/data/trimming.qml"));
+ QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(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;
+}
+
+QTEST_MAIN(tst_qdeclarativeconnection)
+
+#include "tst_qdeclarativeconnection.moc"
diff --git a/tests/auto/declarative/qdeclarativecontext/qdeclarativecontext.pro b/tests/auto/declarative/qdeclarativecontext/qdeclarativecontext.pro
new file mode 100644
index 0000000..adace70
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativecontext/qdeclarativecontext.pro
@@ -0,0 +1,6 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative
+SOURCES += tst_qdeclarativecontext.cpp
+macx:CONFIG -= app_bundle
+
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qdeclarativecontext/tst_qdeclarativecontext.cpp b/tests/auto/declarative/qdeclarativecontext/tst_qdeclarativecontext.cpp
new file mode 100644
index 0000000..5f03989
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativecontext/tst_qdeclarativecontext.cpp
@@ -0,0 +1,434 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+#include <QDebug>
+#include <QDeclarativeEngine>
+#include <QDeclarativeContext>
+#include <QDeclarativeComponent>
+#include <QDeclarativeExpression>
+
+class tst_qdeclarativecontext : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qdeclarativecontext() {}
+
+private slots:
+ void baseUrl();
+ void resolvedUrl();
+ void engineMethod();
+ void parentContext();
+ void setContextProperty();
+ void addDefaultObject();
+ void destruction();
+
+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(), ctxt2);
+ QCOMPARE(ctxt4->parentContext(), ctxt2);
+ 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(), ctxt2);
+ QCOMPARE(ctxt4->parentContext(), ctxt2);
+ QCOMPARE(ctxt5->parentContext(), ctxt);
+ 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;
+};
+
+class TestObject2 : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int b READ b NOTIFY bChanged)
+
+public:
+ TestObject2() : _b(10) {}
+
+ int b() const { return _b; }
+ void setB(int b) { _b = b; emit bChanged(); }
+
+signals:
+ void bChanged();
+
+private:
+ int _b;
+};
+
+#define TEST_CONTEXT_PROPERTY(ctxt, name, value) \
+{ \
+ QDeclarativeComponent component(&engine); \
+ component.setData("import Qt 4.6; QtObject { property var 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 Qt 4.6; QtObject { property var 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 Qt 4.6; QtObject { property var 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 Qt 4.6; QtObject { property var 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 Qt 4.6; QtObject { property var 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 Qt 4.6; QtObject { id: root; property int a: 10; property int test: ctxtProp.a; property var obj: root; }", QUrl());
+
+ QDeclarativeContext ctxt(engine.rootContext());
+ ctxt.setContextProperty("ctxtProp", QVariant());
+
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>:1: TypeError: Result of expression 'ctxtProp' [undefined] is not an object.");
+ 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::addDefaultObject()
+{
+ QDeclarativeContext ctxt(&engine);
+
+ TestObject to;
+ TestObject2 to2;
+
+ to.setA(2);
+ to.setB(192);
+ to.setC(18);
+ to2.setB(111999);
+
+ ctxt.addDefaultObject(&to2);
+ ctxt.addDefaultObject(&to);
+ ctxt.setContextProperty("c", QVariant(9));
+
+ // Static context properties
+ TEST_CONTEXT_PROPERTY(&ctxt, a, QVariant(2));
+ TEST_CONTEXT_PROPERTY(&ctxt, b, QVariant(111999));
+ TEST_CONTEXT_PROPERTY(&ctxt, c, QVariant(9));
+
+ to.setA(12);
+ to.setB(100);
+ to.setC(7);
+ to2.setB(1612);
+ ctxt.setContextProperty("c", QVariant(3));
+
+ TEST_CONTEXT_PROPERTY(&ctxt, a, QVariant(12));
+ TEST_CONTEXT_PROPERTY(&ctxt, b, QVariant(1612));
+ TEST_CONTEXT_PROPERTY(&ctxt, c, QVariant(3));
+
+ // Changes in context properties
+ {
+ QDeclarativeComponent component(&engine);
+ component.setData("import Qt 4.6; QtObject { property var 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, "a", 0);
+
+ QCOMPARE(ctxt, QDeclarativeEngine::contextForObject(&obj));
+ QCOMPARE(ctxt, expr.context());
+
+ delete ctxt; ctxt = 0;
+
+ QCOMPARE(ctxt, QDeclarativeEngine::contextForObject(&obj));
+ QCOMPARE(ctxt, expr.context());
+}
+
+QTEST_MAIN(tst_qdeclarativecontext)
+
+#include "tst_qdeclarativecontext.moc"
diff --git a/tests/auto/declarative/qdeclarativedatetimeformatter/qdeclarativedatetimeformatter.pro b/tests/auto/declarative/qdeclarativedatetimeformatter/qdeclarativedatetimeformatter.pro
new file mode 100644
index 0000000..22f53e6
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativedatetimeformatter/qdeclarativedatetimeformatter.pro
@@ -0,0 +1,5 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qdeclarativedatetimeformatter.cpp
diff --git a/tests/auto/declarative/qdeclarativedatetimeformatter/tst_qdeclarativedatetimeformatter.cpp b/tests/auto/declarative/qdeclarativedatetimeformatter/tst_qdeclarativedatetimeformatter.cpp
new file mode 100644
index 0000000..69d7900
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativedatetimeformatter/tst_qdeclarativedatetimeformatter.cpp
@@ -0,0 +1,150 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QtDeclarative/qdeclarativeengine.h>
+#include <QtDeclarative/qdeclarativecomponent.h>
+#include <private/qdeclarativedatetimeformatter_p.h>
+#include <QDebug>
+
+class tst_qdeclarativedatetimeformatter : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qdeclarativedatetimeformatter() {}
+
+private slots:
+ void date();
+ void time();
+ void dateTime();
+};
+
+void tst_qdeclarativedatetimeformatter::date()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent formatterComponent(&engine);
+ formatterComponent.setData(QByteArray("import Qt 4.6\n DateTimeFormatter { date: \"2008-12-24\" }"),
+ QUrl::fromLocalFile(""));
+ QDeclarativeDateTimeFormatter *formatter = qobject_cast<QDeclarativeDateTimeFormatter*>(formatterComponent.create());
+ if(formatterComponent.isError())
+ qDebug() << formatterComponent.errors();
+ QVERIFY(formatter != 0);
+
+ QDate date(2008,12,24);
+ QCOMPARE(formatter->date(), date);
+ QCOMPARE(formatter->dateTime().date(), date);
+ QCOMPARE(formatter->dateText(),date.toString(Qt::SystemLocaleShortDate));
+
+ formatter->setLongStyle(true);
+ QVERIFY(formatter->longStyle());
+ QCOMPARE(formatter->dateText(),date.toString(Qt::SystemLocaleLongDate));
+
+ formatter->setDateFormat("ddd MMMM d yy");
+ QCOMPARE(formatter->dateFormat(), QLatin1String("ddd MMMM d yy"));
+ QCOMPARE(formatter->dateText(),date.toString("ddd MMMM d yy"));
+
+ QVERIFY(formatter->timeText().isEmpty());
+ QVERIFY(formatter->dateTimeText().isEmpty());
+
+ delete formatter;
+}
+
+void tst_qdeclarativedatetimeformatter::time()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent formatterComponent(&engine);
+ formatterComponent.setData("import Qt 4.6\n DateTimeFormatter { time: \"14:15:38.200\" }", QUrl::fromLocalFile(""));
+ QDeclarativeDateTimeFormatter *formatter = qobject_cast<QDeclarativeDateTimeFormatter*>(formatterComponent.create());
+ if(formatterComponent.isError())
+ qDebug() << formatterComponent.errors();
+ QVERIFY(formatter != 0);
+
+ QTime time(14,15,38,200);
+
+ QCOMPARE(formatter->time(),time);
+ QCOMPARE(formatter->dateTime().time(),time);
+
+ QCOMPARE(formatter->timeText(),time.toString(Qt::SystemLocaleShortDate));
+
+ formatter->setLongStyle(true);
+ QCOMPARE(formatter->timeText(),time.toString(Qt::SystemLocaleLongDate));
+
+ formatter->setTimeFormat("H:m:s a");
+ QCOMPARE(formatter->timeFormat(), QLatin1String("H:m:s a"));
+ QCOMPARE(formatter->timeText(),time.toString("H:m:s a"));
+
+ formatter->setTimeFormat("hh:mm:ss.zzz");
+ QCOMPARE(formatter->timeText(),time.toString("hh:mm:ss.zzz"));
+
+ QVERIFY(formatter->dateText().isEmpty());
+ QVERIFY(formatter->dateTimeText().isEmpty());
+
+ delete formatter;
+}
+
+void tst_qdeclarativedatetimeformatter::dateTime()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent formatterComponent(&engine);
+ formatterComponent.setData("import Qt 4.6\n DateTimeFormatter { dateTime: \"1978-03-04T09:13:54\" }", QUrl::fromLocalFile(""));
+ QDeclarativeDateTimeFormatter *formatter = qobject_cast<QDeclarativeDateTimeFormatter*>(formatterComponent.create());
+ if(formatterComponent.isError())
+ qDebug() << formatterComponent.errors();
+ QVERIFY(formatter != 0);
+
+ QDateTime dateTime(QDate(1978,03,04),QTime(9,13,54));
+ QCOMPARE(formatter->dateTime(),dateTime);
+ QCOMPARE(formatter->date(),dateTime.date());
+ QCOMPARE(formatter->time(),dateTime.time());
+ QCOMPARE(formatter->dateTimeText(),dateTime.toString(Qt::SystemLocaleShortDate));
+
+ formatter->setLongStyle(true);
+ QCOMPARE(formatter->dateTimeText(),dateTime.toString(Qt::SystemLocaleLongDate));
+
+ formatter->setDateTimeFormat("M/d/yy H:m:s a");
+ QCOMPARE(formatter->dateTimeFormat(), QLatin1String("M/d/yy H:m:s a"));
+ QCOMPARE(formatter->dateTimeText(),dateTime.toString("M/d/yy H:m:s a"));
+
+ delete formatter;
+}
+
+QTEST_MAIN(tst_qdeclarativedatetimeformatter)
+
+#include "tst_qdeclarativedatetimeformatter.moc"
diff --git a/tests/auto/declarative/qdeclarativedebug/qdeclarativedebug.pro b/tests/auto/declarative/qdeclarativedebug/qdeclarativedebug.pro
new file mode 100644
index 0000000..ff1d0d4
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativedebug/qdeclarativedebug.pro
@@ -0,0 +1,7 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += network declarative
+macx:CONFIG -= app_bundle
+
+HEADERS += ../shared/debugutil_p.h
+SOURCES += tst_qdeclarativedebug.cpp \
+ ../shared/debugutil.cpp
diff --git a/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp b/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp
new file mode 100644
index 0000000..0c3ca76
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp
@@ -0,0 +1,843 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <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 <private/qdeclarativebinding_p.h>
+#include <private/qdeclarativedebug_p.h>
+#include <private/qdeclarativeenginedebug_p.h>
+#include <private/qdeclarativedebugclient_p.h>
+#include <private/qdeclarativedebugservice_p.h>
+#include <private/qdeclarativerectangle_p.h>
+#include <private/qdeclarativemetatype_p.h>
+#include <private/qdeclarativeproperty_p.h>
+
+#include "../shared/debugutil_p.h"
+
+Q_DECLARE_METATYPE(QDeclarativeDebugWatch::State)
+
+
+class tst_QDeclarativeDebug : public QObject
+{
+ Q_OBJECT
+
+public:
+ tst_QDeclarativeDebug(QDeclarativeDebugTestData *data)
+ {
+ m_conn = data->conn;
+ m_engine = data->engine;
+ m_rootItem = data->items[0];
+ }
+
+private:
+ QDeclarativeDebugObjectReference findRootObject();
+ 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;
+ QDeclarativeItem *m_rootItem;
+
+private slots:
+ void initTestCase();
+
+ 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();
+};
+
+QDeclarativeDebugObjectReference tst_QDeclarativeDebug::findRootObject()
+{
+ 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 = m_dbg->queryObject(q_context->rootContext().objects()[0], this);
+ waitForQuery(q_obj);
+
+ QDeclarativeDebugObjectReference result = q_obj->object();
+
+ delete q_engines;
+ delete q_context;
+ delete q_obj;
+
+ return result;
+}
+
+QDeclarativeDebugPropertyReference tst_QDeclarativeDebug::findProperty(const QList<QDeclarativeDebugPropertyReference> &props, const QString &name) const
+{
+ foreach(const QDeclarativeDebugPropertyReference &p, props) {
+ if (p.name() == name)
+ return p;
+ }
+ return QDeclarativeDebugPropertyReference();
+}
+
+void tst_QDeclarativeDebug::waitForQuery(QDeclarativeDebugQuery *query)
+{
+ QVERIFY(query);
+ QCOMPARE(query->parent(), this);
+ QVERIFY(query->state() == QDeclarativeDebugQuery::Waiting);
+ if (!QDeclarativeDebugTest::waitForSignal(query, SIGNAL(stateChanged(QDeclarativeDebugQuery::State))))
+ QFAIL("query timed out");
+}
+
+void tst_QDeclarativeDebug::recursiveObjectTest(QObject *o, const QDeclarativeDebugObjectReference &oref, bool recursive) const
+{
+ const QMetaObject *meta = o->metaObject();
+
+ QDeclarativeType *type = QDeclarativeMetaType::qmlType(o->metaObject());
+ QString className = type ? type->qmlTypeName() : QString();
+ 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()) {
+ QVERIFY(p.value().toString().startsWith('{') && p.value().toString().endsWith('}'));
+ 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) // TODO test complex types
+ QCOMPARE(p.value(), pmeta.read(o));
+
+ if (p.name() == "parent")
+ QVERIFY(p.valueTypeName() == "QGraphicsObject*" || p.valueTypeName() == "QDeclarativeItem*");
+ 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_QDeclarativeDebug::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_QDeclarativeDebug::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_QDeclarativeDebug::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_QDeclarativeDebug::initTestCase()
+{
+ m_dbg = new QDeclarativeEngineDebug(m_conn, this);
+
+ qRegisterMetaType<QDeclarativeDebugWatch::State>();
+}
+
+void tst_QDeclarativeDebug::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_QDeclarativeDebug::watch_object()
+{
+ QDeclarativeDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this);
+ waitForQuery(q_engines);
+
+ Q_ASSERT(q_engines->engines().count() > 0);
+ QDeclarativeDebugRootContextQuery *q_context = m_dbg->queryRootContexts(q_engines->engines()[0].debugId(), this);
+ waitForQuery(q_context);
+
+ Q_ASSERT(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_QDeclarativeDebug::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_QDeclarativeDebug::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_QDeclarativeDebug::watch_context()
+{
+ QDeclarativeDebugContextReference c;
+ QTest::ignoreMessage(QtWarningMsg, "QDeclarativeEngineDebug::addWatch(): Not implemented");
+ QVERIFY(!m_dbg->addWatch(c, QString(), this));
+}
+
+void tst_QDeclarativeDebug::watch_file()
+{
+ QDeclarativeDebugFileReference f;
+ QTest::ignoreMessage(QtWarningMsg, "QDeclarativeEngineDebug::addWatch(): Not implemented");
+ QVERIFY(!m_dbg->addWatch(f, this));
+}
+
+void tst_QDeclarativeDebug::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());
+ }
+
+ delete q_engines;
+}
+
+void tst_QDeclarativeDebug::queryRootContexts()
+{
+ QDeclarativeDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this);
+ waitForQuery(q_engines);
+ int engineId = q_engines->engines()[0].debugId();
+
+ 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(), 2); // 2 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(), 1);
+ QVERIFY(context.contexts()[0].debugId() >= 0);
+ QCOMPARE(context.contexts()[0].name(), QString("tst_QDeclarativeDebug_childContext"));
+
+ delete q_engines;
+ delete q_context;
+}
+
+void tst_QDeclarativeDebug::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;
+ delete q_obj;
+
+ // check source as defined in main()
+ QDeclarativeDebugFileReference source = obj.source();
+ QCOMPARE(source.url(), QUrl::fromLocalFile(""));
+ QCOMPARE(source.lineNumber(), 2);
+ 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_QDeclarativeDebug::queryObject_data()
+{
+ QTest::addColumn<bool>("recursive");
+
+ QTest::newRow("non-recursive") << false;
+ QTest::newRow("recursive") << true;
+}
+
+void tst_QDeclarativeDebug::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(), expr);
+ waitForQuery(q_expr);
+
+ QCOMPARE(q_expr->result(), result);
+
+ delete q_engines;
+ delete q_context;
+ delete q_expr;
+}
+
+void tst_QDeclarativeDebug::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>"));
+}
+
+void tst_QDeclarativeDebug::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_QDeclarativeDebug::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_QDeclarativeDebug::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_QDeclarativeDebug::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_QDeclarativeDebug::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);
+}
+
+
+class tst_QDeclarativeDebug_Factory : public QDeclarativeTestFactory
+{
+public:
+ QObject *createTest(QDeclarativeDebugTestData *data)
+ {
+ tst_QDeclarativeDebug *test = new tst_QDeclarativeDebug(data);
+ QDeclarativeContext *c = new QDeclarativeContext(data->engine->rootContext(), test);
+ c->setObjectName("tst_QDeclarativeDebug_childContext");
+ return test;
+ }
+};
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ QList<QByteArray> qml;
+ qml << "import Qt 4.6\n"
+ "Item {"
+ "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') }"
+ "}"
+ "}";
+ // add second component to test multiple root contexts
+ qml << "import Qt 4.6\n"
+ "Item {}";
+ tst_QDeclarativeDebug_Factory factory;
+ return QDeclarativeDebugTest::runTests(&factory, qml);
+}
+
+//QTEST_MAIN(tst_QDeclarativeDebug)
+
+#include "tst_qdeclarativedebug.moc"
diff --git a/tests/auto/declarative/qdeclarativedebugclient/qdeclarativedebugclient.pro b/tests/auto/declarative/qdeclarativedebugclient/qdeclarativedebugclient.pro
new file mode 100644
index 0000000..a3afd99
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativedebugclient/qdeclarativedebugclient.pro
@@ -0,0 +1,7 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += network declarative
+macx:CONFIG -= app_bundle
+
+HEADERS += ../shared/debugutil_p.h
+SOURCES += tst_qdeclarativedebugclient.cpp \
+ ../shared/debugutil.cpp
diff --git a/tests/auto/declarative/qdeclarativedebugclient/tst_qdeclarativedebugclient.cpp b/tests/auto/declarative/qdeclarativedebugclient/tst_qdeclarativedebugclient.cpp
new file mode 100644
index 0000000..d3679a7
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativedebugclient/tst_qdeclarativedebugclient.cpp
@@ -0,0 +1,157 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QSignalSpy>
+#include <QTimer>
+#include <QHostAddress>
+#include <QDebug>
+#include <QThread>
+
+#include <QtDeclarative/qdeclarativeengine.h>
+
+#include <private/qdeclarativedebug_p.h>
+#include <private/qdeclarativeenginedebug_p.h>
+#include <private/qdeclarativedebugclient_p.h>
+#include <private/qdeclarativedebugservice_p.h>
+
+#include "../shared/debugutil_p.h"
+
+class tst_QDeclarativeDebugClient : public QObject
+{
+ Q_OBJECT
+
+public:
+ tst_QDeclarativeDebugClient(QDeclarativeDebugTestData *data)
+ {
+ m_conn = data->conn;
+ }
+
+ QDeclarativeDebugConnection *m_conn;
+
+private slots:
+ void name();
+ void isEnabled();
+ void setEnabled();
+ void isConnected();
+ void sendMessage();
+};
+
+void tst_QDeclarativeDebugClient::name()
+{
+ QString name = "tst_QDeclarativeDebugClient::name()";
+
+ QDeclarativeDebugClient client(name, m_conn);
+ QCOMPARE(client.name(), name);
+}
+
+void tst_QDeclarativeDebugClient::isEnabled()
+{
+ QDeclarativeDebugClient client("tst_QDeclarativeDebugClient::isEnabled()", m_conn);
+ QCOMPARE(client.isEnabled(), false);
+}
+
+void tst_QDeclarativeDebugClient::setEnabled()
+{
+ QDeclarativeDebugTestService service("tst_QDeclarativeDebugClient::setEnabled()");
+ QDeclarativeDebugTestClient client("tst_QDeclarativeDebugClient::setEnabled()", m_conn);
+
+ QCOMPARE(service.isEnabled(), false);
+
+ client.setEnabled(true);
+ QCOMPARE(client.isEnabled(), true);
+ QDeclarativeDebugTest::waitForSignal(&service, SIGNAL(enabledStateChanged()));
+ QCOMPARE(service.isEnabled(), true);
+
+ client.setEnabled(false);
+ QCOMPARE(client.isEnabled(), false);
+ QDeclarativeDebugTest::waitForSignal(&service, SIGNAL(enabledStateChanged()));
+ QCOMPARE(service.isEnabled(), false);
+}
+
+void tst_QDeclarativeDebugClient::isConnected()
+{
+ QDeclarativeDebugClient client1("tst_QDeclarativeDebugClient::isConnected() A", m_conn);
+ QCOMPARE(client1.isConnected(), true);
+
+ QDeclarativeDebugConnection conn;
+ QDeclarativeDebugClient client2("tst_QDeclarativeDebugClient::isConnected() B", &conn);
+ QCOMPARE(client2.isConnected(), false);
+
+ QDeclarativeDebugClient client3("tst_QDeclarativeDebugClient::isConnected() C", 0);
+ QCOMPARE(client3.isConnected(), false);
+
+ // duplicate plugin name
+ QTest::ignoreMessage(QtWarningMsg, "QDeclarativeDebugClient: Conflicting plugin name \"tst_QDeclarativeDebugClient::isConnected() A\" ");
+ QDeclarativeDebugClient client4("tst_QDeclarativeDebugClient::isConnected() A", m_conn);
+ QCOMPARE(client4.isConnected(), false);
+}
+
+void tst_QDeclarativeDebugClient::sendMessage()
+{
+ QDeclarativeDebugTestService service("tst_QDeclarativeDebugClient::sendMessage()");
+ QDeclarativeDebugTestClient client("tst_QDeclarativeDebugClient::sendMessage()", m_conn);
+
+ QByteArray msg = "hello!";
+
+ client.sendMessage(msg);
+ QByteArray resp = client.waitForResponse();
+ QCOMPARE(resp, msg);
+}
+
+
+class tst_QDeclarativeDebugClient_Factory : public QDeclarativeTestFactory
+{
+public:
+ QObject *createTest(QDeclarativeDebugTestData *data) { return new tst_QDeclarativeDebugClient(data); }
+};
+
+
+// This does not use QTEST_MAIN because the test has to be created and run
+// in a separate thread.
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ tst_QDeclarativeDebugClient_Factory factory;
+ return QDeclarativeDebugTest::runTests(&factory);
+}
+
+#include "tst_qdeclarativedebugclient.moc"
diff --git a/tests/auto/declarative/qdeclarativedebugservice/qdeclarativedebugservice.pro b/tests/auto/declarative/qdeclarativedebugservice/qdeclarativedebugservice.pro
new file mode 100644
index 0000000..e375889
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativedebugservice/qdeclarativedebugservice.pro
@@ -0,0 +1,7 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += network declarative
+macx:CONFIG -= app_bundle
+
+HEADERS += ../shared/debugutil_p.h
+SOURCES += tst_qdeclarativedebugservice.cpp \
+ ../shared/debugutil.cpp
diff --git a/tests/auto/declarative/qdeclarativedebugservice/tst_qdeclarativedebugservice.cpp b/tests/auto/declarative/qdeclarativedebugservice/tst_qdeclarativedebugservice.cpp
new file mode 100644
index 0000000..c8fc001
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativedebugservice/tst_qdeclarativedebugservice.cpp
@@ -0,0 +1,190 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QSignalSpy>
+#include <QTimer>
+#include <QHostAddress>
+#include <QDebug>
+#include <QThread>
+
+#include <QtDeclarative/qdeclarativeengine.h>
+
+#include <private/qdeclarativedebug_p.h>
+#include <private/qdeclarativeenginedebug_p.h>
+#include <private/qdeclarativedebugclient_p.h>
+#include <private/qdeclarativedebugservice_p.h>
+
+#include "../shared/debugutil_p.h"
+
+class tst_QDeclarativeDebugService : public QObject
+{
+ Q_OBJECT
+
+public:
+ tst_QDeclarativeDebugService(QDeclarativeDebugTestData *data)
+ {
+ m_conn = data->conn;
+ }
+
+ QDeclarativeDebugConnection *m_conn;
+
+private slots:
+ void name();
+ void isEnabled();
+ void enabledChanged();
+ void sendMessage();
+ void idForObject();
+ void objectForId();
+ void objectToString();
+};
+
+void tst_QDeclarativeDebugService::name()
+{
+ QString name = "tst_QDeclarativeDebugService::name()";
+
+ QDeclarativeDebugService service(name);
+ QCOMPARE(service.name(), name);
+}
+
+void tst_QDeclarativeDebugService::isEnabled()
+{
+ QDeclarativeDebugTestService service("tst_QDeclarativeDebugService::isEnabled()", m_conn);
+ QCOMPARE(service.isEnabled(), false);
+
+ QDeclarativeDebugTestClient client("tst_QDeclarativeDebugService::isEnabled()", m_conn);
+ client.setEnabled(true);
+ QDeclarativeDebugTest::waitForSignal(&service, SIGNAL(enabledStateChanged()));
+ QCOMPARE(service.isEnabled(), true);
+
+ QTest::ignoreMessage(QtWarningMsg, "QDeclarativeDebugService: Conflicting plugin name \"tst_QDeclarativeDebugService::isEnabled()\" ");
+ QDeclarativeDebugService duplicate("tst_QDeclarativeDebugService::isEnabled()", m_conn);
+ QCOMPARE(duplicate.isEnabled(), false);
+}
+
+void tst_QDeclarativeDebugService::enabledChanged()
+{
+ QDeclarativeDebugTestService service("tst_QDeclarativeDebugService::enabledChanged()");
+ QDeclarativeDebugTestClient client("tst_QDeclarativeDebugService::enabledChanged()", m_conn);
+
+ QCOMPARE(service.enabled, false);
+
+ client.setEnabled(true);
+ QDeclarativeDebugTest::waitForSignal(&service, SIGNAL(enabledStateChanged()));
+ QCOMPARE(service.enabled, true);
+}
+
+void tst_QDeclarativeDebugService::sendMessage()
+{
+ QDeclarativeDebugTestService service("tst_QDeclarativeDebugService::sendMessage()");
+ QDeclarativeDebugTestClient client("tst_QDeclarativeDebugService::sendMessage()", m_conn);
+
+ QByteArray msg = "hello!";
+
+ client.sendMessage(msg);
+ QByteArray resp = client.waitForResponse();
+ QCOMPARE(resp, 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;
+}
+
+
+class tst_QDeclarativeDebugService_Factory : public QDeclarativeTestFactory
+{
+public:
+ QObject *createTest(QDeclarativeDebugTestData *data) { return new tst_QDeclarativeDebugService(data); }
+};
+
+// This does not use QTEST_MAIN because the test has to be created and run
+// in a separate thread.
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ tst_QDeclarativeDebugService_Factory factory;
+ return QDeclarativeDebugTest::runTests(&factory);
+}
+
+#include "tst_qdeclarativedebugservice.moc"
diff --git a/tests/auto/declarative/qmldom/data/MyComponent.qml b/tests/auto/declarative/qdeclarativedom/data/MyComponent.qml
index 1472f01..1472f01 100644
--- a/tests/auto/declarative/qmldom/data/MyComponent.qml
+++ b/tests/auto/declarative/qdeclarativedom/data/MyComponent.qml
diff --git a/tests/auto/declarative/qmldom/data/MyItem.qml b/tests/auto/declarative/qdeclarativedom/data/MyItem.qml
index 1472f01..1472f01 100644
--- a/tests/auto/declarative/qmldom/data/MyItem.qml
+++ b/tests/auto/declarative/qdeclarativedom/data/MyItem.qml
diff --git a/tests/auto/declarative/qmldom/data/importdir/Bar.qml b/tests/auto/declarative/qdeclarativedom/data/importdir/Bar.qml
index 2d1a4a3..2d1a4a3 100644
--- a/tests/auto/declarative/qmldom/data/importdir/Bar.qml
+++ b/tests/auto/declarative/qdeclarativedom/data/importdir/Bar.qml
diff --git a/tests/auto/declarative/qmldom/data/importlib/sublib/qmldir/Foo.qml b/tests/auto/declarative/qdeclarativedom/data/importlib/sublib/qmldir/Foo.qml
index 2d1a4a3..2d1a4a3 100644
--- a/tests/auto/declarative/qmldom/data/importlib/sublib/qmldir/Foo.qml
+++ b/tests/auto/declarative/qdeclarativedom/data/importlib/sublib/qmldir/Foo.qml
diff --git a/tests/auto/declarative/qmldom/data/top.qml b/tests/auto/declarative/qdeclarativedom/data/top.qml
index 2681993..2681993 100644
--- a/tests/auto/declarative/qmldom/data/top.qml
+++ b/tests/auto/declarative/qdeclarativedom/data/top.qml
diff --git a/tests/auto/declarative/qdeclarativedom/qdeclarativedom.pro b/tests/auto/declarative/qdeclarativedom/qdeclarativedom.pro
new file mode 100644
index 0000000..35df26e
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativedom/qdeclarativedom.pro
@@ -0,0 +1,7 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qdeclarativedom.cpp
+
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qdeclarativedom/tst_qdeclarativedom.cpp b/tests/auto/declarative/qdeclarativedom/tst_qdeclarativedom.cpp
new file mode 100644
index 0000000..9543280
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativedom/tst_qdeclarativedom.cpp
@@ -0,0 +1,1313 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QtDeclarative/qdeclarativeengine.h>
+#include <QtDeclarative/qdeclarativecomponent.h>
+#include <QtDeclarative/private/qdeclarativedom_p.h>
+
+#include <QtCore/QDebug>
+#include <QtCore/QFile>
+
+class tst_qdeclarativedom : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qdeclarativedom() {}
+
+private slots:
+ void loadSimple();
+ void loadProperties();
+ void loadGroupedProperties();
+ void loadChildObject();
+ void loadComposite();
+ void loadImports();
+ void loadErrors();
+ void loadSyntaxErrors();
+ void loadRemoteErrors();
+ void loadDynamicProperty();
+ void loadComponent();
+
+ void testValueSource();
+ void testValueInterceptor();
+
+ void object_dynamicProperty();
+ void object_property();
+ void object_url();
+
+ void copy();
+ void position();
+private:
+ QDeclarativeEngine engine;
+};
+
+
+void tst_qdeclarativedom::loadSimple()
+{
+ QByteArray qml = "import Qt 4.6\n"
+ "Item {}";
+
+ QDeclarativeDomDocument document;
+ QVERIFY(document.load(&engine, qml));
+ QVERIFY(document.errors().isEmpty());
+
+ QDeclarativeDomObject rootObject = document.rootObject();
+ QVERIFY(rootObject.isValid());
+ QVERIFY(!rootObject.isComponent());
+ QVERIFY(!rootObject.isCustomType());
+ QVERIFY(rootObject.objectType() == "Qt/Item");
+ QVERIFY(rootObject.objectTypeMajorVersion() == 4);
+ QVERIFY(rootObject.objectTypeMinorVersion() == 6);
+}
+
+// Test regular properties
+void tst_qdeclarativedom::loadProperties()
+{
+ QByteArray qml = "import Qt 4.6\n"
+ "Item { id : item; x : 300; visible : true }";
+
+ QDeclarativeDomDocument document;
+ QVERIFY(document.load(&engine, qml));
+
+ QDeclarativeDomObject rootObject = document.rootObject();
+ QVERIFY(rootObject.isValid());
+ QVERIFY(rootObject.objectId() == "item");
+ QCOMPARE(rootObject.properties().size(), 3);
+
+ QDeclarativeDomProperty xProperty = rootObject.property("x");
+ QVERIFY(xProperty.propertyName() == "x");
+ QCOMPARE(xProperty.propertyNameParts().count(), 1);
+ QVERIFY(xProperty.propertyNameParts().at(0) == "x");
+ QCOMPARE(xProperty.position(), 32);
+ QCOMPARE(xProperty.length(), 1);
+ QVERIFY(xProperty.value().isLiteral());
+ QVERIFY(xProperty.value().toLiteral().literal() == "300");
+
+ QDeclarativeDomProperty visibleProperty = rootObject.property("visible");
+ QVERIFY(visibleProperty.propertyName() == "visible");
+ QCOMPARE(visibleProperty.propertyNameParts().count(), 1);
+ QVERIFY(visibleProperty.propertyNameParts().at(0) == "visible");
+ QCOMPARE(visibleProperty.position(), 41);
+ QCOMPARE(visibleProperty.length(), 7);
+ QVERIFY(visibleProperty.value().isLiteral());
+ QVERIFY(visibleProperty.value().toLiteral().literal() == "true");
+}
+
+// Test grouped properties
+void tst_qdeclarativedom::loadGroupedProperties()
+{
+ {
+ QByteArray qml = "import Qt 4.6\n"
+ "Item { anchors.left: parent.left; anchors.right: parent.right }";
+
+ QDeclarativeDomDocument document;
+ QVERIFY(document.load(&engine, qml));
+
+ QDeclarativeDomObject rootItem = document.rootObject();
+ QVERIFY(rootItem.isValid());
+ QVERIFY(rootItem.properties().size() == 2);
+
+ // Order is not deterministic
+ QDeclarativeDomProperty p0 = rootItem.properties().at(0);
+ QDeclarativeDomProperty p1 = rootItem.properties().at(1);
+ QDeclarativeDomProperty leftProperty;
+ QDeclarativeDomProperty rightProperty;
+ if (p0.propertyName() == "anchors.left") {
+ leftProperty = p0;
+ rightProperty = p1;
+ } else {
+ leftProperty = p1;
+ rightProperty = p0;
+ }
+
+ QVERIFY(leftProperty.propertyName() == "anchors.left");
+ QCOMPARE(leftProperty.propertyNameParts().count(), 2);
+ QVERIFY(leftProperty.propertyNameParts().at(0) == "anchors");
+ QVERIFY(leftProperty.propertyNameParts().at(1) == "left");
+ QCOMPARE(leftProperty.position(), 21);
+ QCOMPARE(leftProperty.length(), 12);
+ QVERIFY(leftProperty.value().isBinding());
+ QVERIFY(leftProperty.value().toBinding().binding() == "parent.left");
+
+ QVERIFY(rightProperty.propertyName() == "anchors.right");
+ QCOMPARE(rightProperty.propertyNameParts().count(), 2);
+ QVERIFY(rightProperty.propertyNameParts().at(0) == "anchors");
+ QVERIFY(rightProperty.propertyNameParts().at(1) == "right");
+ QCOMPARE(rightProperty.position(), 48);
+ QCOMPARE(rightProperty.length(), 13);
+ QVERIFY(rightProperty.value().isBinding());
+ QVERIFY(rightProperty.value().toBinding().binding() == "parent.right");
+ }
+
+ {
+ QByteArray qml = "import Qt 4.6\n"
+ "Item { \n"
+ " anchors {\n"
+ " left: parent.left\n"
+ " right: parent.right\n"
+ " }\n"
+ "}";
+
+ QDeclarativeDomDocument document;
+ QVERIFY(document.load(&engine, qml));
+
+ QDeclarativeDomObject rootItem = document.rootObject();
+ QVERIFY(rootItem.isValid());
+ QVERIFY(rootItem.properties().size() == 2);
+
+ // Order is not deterministic
+ QDeclarativeDomProperty p0 = rootItem.properties().at(0);
+ QDeclarativeDomProperty p1 = rootItem.properties().at(1);
+ QDeclarativeDomProperty leftProperty;
+ QDeclarativeDomProperty rightProperty;
+ if (p0.propertyName() == "anchors.left") {
+ leftProperty = p0;
+ rightProperty = p1;
+ } else {
+ leftProperty = p1;
+ rightProperty = p0;
+ }
+
+ QVERIFY(leftProperty.propertyName() == "anchors.left");
+ QCOMPARE(leftProperty.propertyNameParts().count(), 2);
+ QVERIFY(leftProperty.propertyNameParts().at(0) == "anchors");
+ QVERIFY(leftProperty.propertyNameParts().at(1) == "left");
+ QCOMPARE(leftProperty.position(), 44);
+ QCOMPARE(leftProperty.length(), 4);
+ QVERIFY(leftProperty.value().isBinding());
+ QVERIFY(leftProperty.value().toBinding().binding() == "parent.left");
+
+ QVERIFY(rightProperty.propertyName() == "anchors.right");
+ QCOMPARE(rightProperty.propertyNameParts().count(), 2);
+ QVERIFY(rightProperty.propertyNameParts().at(0) == "anchors");
+ QVERIFY(rightProperty.propertyNameParts().at(1) == "right");
+ QCOMPARE(rightProperty.position(), 70);
+ QCOMPARE(rightProperty.length(), 5);
+ QVERIFY(rightProperty.value().isBinding());
+ QVERIFY(rightProperty.value().toBinding().binding() == "parent.right");
+ }
+
+}
+
+void tst_qdeclarativedom::loadChildObject()
+{
+ QByteArray qml = "import Qt 4.6\n"
+ "Item { Item {} }";
+
+ QDeclarativeDomDocument document;
+ QVERIFY(document.load(&engine, qml));
+
+ QDeclarativeDomObject rootItem = document.rootObject();
+ QVERIFY(rootItem.isValid());
+ QVERIFY(rootItem.properties().size() == 1);
+
+ QDeclarativeDomProperty listProperty = rootItem.properties().at(0);
+ QVERIFY(listProperty.isDefaultProperty());
+ QVERIFY(listProperty.value().isList());
+
+ QDeclarativeDomList list = listProperty.value().toList();
+ QVERIFY(list.values().size() == 1);
+
+ QDeclarativeDomObject childItem = list.values().first().toObject();
+ QVERIFY(childItem.isValid());
+ QVERIFY(childItem.objectType() == "Qt/Item");
+}
+
+void tst_qdeclarativedom::loadComposite()
+{
+ QFile file(SRCDIR "/data/top.qml");
+ QVERIFY(file.open(QIODevice::ReadOnly | QIODevice::Text));
+
+ QDeclarativeDomDocument document;
+ QVERIFY(document.load(&engine, file.readAll(), QUrl::fromLocalFile(file.fileName())));
+ QVERIFY(document.errors().isEmpty());
+
+ QDeclarativeDomObject rootItem = document.rootObject();
+ QVERIFY(rootItem.isValid());
+ QCOMPARE(rootItem.objectType(), QByteArray("MyComponent"));
+ QCOMPARE(rootItem.properties().size(), 2);
+
+ QDeclarativeDomProperty widthProperty = rootItem.property("width");
+ QVERIFY(widthProperty.value().isLiteral());
+
+ QDeclarativeDomProperty heightProperty = rootItem.property("height");
+ QVERIFY(heightProperty.value().isLiteral());
+}
+
+void tst_qdeclarativedom::testValueSource()
+{
+ QByteArray qml = "import Qt 4.6\n"
+ "Rectangle { height: SpringFollow { spring: 1.4; damping: .15; source: Math.min(Math.max(-130, value*2.2 - 130), 133); }}";
+
+ QDeclarativeEngine freshEngine;
+ QDeclarativeDomDocument document;
+ QVERIFY(document.load(&freshEngine, qml));
+
+ QDeclarativeDomObject rootItem = document.rootObject();
+ QVERIFY(rootItem.isValid());
+ QDeclarativeDomProperty heightProperty = rootItem.properties().at(0);
+ QVERIFY(heightProperty.propertyName() == "height");
+ QVERIFY(heightProperty.value().isValueSource());
+
+ const QDeclarativeDomValueValueSource valueSource = heightProperty.value().toValueSource();
+ QDeclarativeDomObject valueSourceObject = valueSource.object();
+ QVERIFY(valueSourceObject.isValid());
+
+ QVERIFY(valueSourceObject.objectType() == "Qt/SpringFollow");
+
+ const QDeclarativeDomValue springValue = valueSourceObject.property("spring").value();
+ QVERIFY(!springValue.isInvalid());
+ QVERIFY(springValue.isLiteral());
+ QVERIFY(springValue.toLiteral().literal() == "1.4");
+
+ const QDeclarativeDomValue sourceValue = valueSourceObject.property("source").value();
+ QVERIFY(!sourceValue.isInvalid());
+ QVERIFY(sourceValue.isBinding());
+ QVERIFY(sourceValue.toBinding().binding() == "Math.min(Math.max(-130, value*2.2 - 130), 133)");
+}
+
+void tst_qdeclarativedom::testValueInterceptor()
+{
+ QByteArray qml = "import Qt 4.6\n"
+ "Rectangle { height: Behavior { NumberAnimation { duration: 100 } } }";
+
+ QDeclarativeEngine freshEngine;
+ QDeclarativeDomDocument document;
+ QVERIFY(document.load(&freshEngine, qml));
+
+ QDeclarativeDomObject rootItem = document.rootObject();
+ QVERIFY(rootItem.isValid());
+ QDeclarativeDomProperty heightProperty = rootItem.properties().at(0);
+ QVERIFY(heightProperty.propertyName() == "height");
+ QVERIFY(heightProperty.value().isValueInterceptor());
+
+ const QDeclarativeDomValueValueInterceptor valueInterceptor = heightProperty.value().toValueInterceptor();
+ QDeclarativeDomObject valueInterceptorObject = valueInterceptor.object();
+ QVERIFY(valueInterceptorObject.isValid());
+
+ QVERIFY(valueInterceptorObject.objectType() == "Qt/Behavior");
+
+ const QDeclarativeDomValue animationValue = valueInterceptorObject.property("animation").value();
+ QVERIFY(!animationValue.isInvalid());
+ QVERIFY(animationValue.isObject());
+}
+
+// Test QDeclarativeDomDocument::imports()
+void tst_qdeclarativedom::loadImports()
+{
+ QByteArray qml = "import Qt 4.6\n"
+ "import importlib.sublib 4.7\n"
+ "import importlib.sublib 4.6 as NewFoo\n"
+ "import 'import'\n"
+ "import 'import' as X\n"
+ "Item {}";
+
+ QDeclarativeEngine engine;
+ engine.addImportPath(SRCDIR "/data");
+ QDeclarativeDomDocument document;
+ QVERIFY(document.load(&engine, qml));
+
+ QCOMPARE(document.imports().size(), 5);
+
+ QDeclarativeDomImport import = document.imports().at(0);
+ QCOMPARE(import.type(), QDeclarativeDomImport::Library);
+ QCOMPARE(import.uri(), QLatin1String("Qt"));
+ QCOMPARE(import.qualifier(), QString());
+ QCOMPARE(import.version(), QLatin1String("4.6"));
+
+ import = document.imports().at(1);
+ QCOMPARE(import.type(), QDeclarativeDomImport::Library);
+ QCOMPARE(import.uri(), QLatin1String("importlib.sublib"));
+ QCOMPARE(import.qualifier(), QString());
+ QCOMPARE(import.version(), QLatin1String("4.7"));
+
+ import = document.imports().at(2);
+ QCOMPARE(import.type(), QDeclarativeDomImport::Library);
+ QCOMPARE(import.uri(), QLatin1String("importlib.sublib"));
+ QCOMPARE(import.qualifier(), QLatin1String("NewFoo"));
+ QCOMPARE(import.version(), QLatin1String("4.6"));
+
+ import = document.imports().at(3);
+ QCOMPARE(import.type(), QDeclarativeDomImport::File);
+ QCOMPARE(import.uri(), QLatin1String("import"));
+ QCOMPARE(import.qualifier(), QLatin1String(""));
+ QCOMPARE(import.version(), QLatin1String(""));
+
+ import = document.imports().at(4);
+ QCOMPARE(import.type(), QDeclarativeDomImport::File);
+ QCOMPARE(import.uri(), QLatin1String("import"));
+ QCOMPARE(import.qualifier(), QLatin1String("X"));
+ QCOMPARE(import.version(), QLatin1String(""));
+}
+
+// Test loading a file with errors
+void tst_qdeclarativedom::loadErrors()
+{
+ QByteArray qml = "import Qt 4.6\n"
+ "Item {\n"
+ " foo: 12\n"
+ "}";
+
+ QDeclarativeDomDocument document;
+ QVERIFY(false == document.load(&engine, qml));
+
+ QCOMPARE(document.errors().count(), 1);
+ QDeclarativeError error = document.errors().first();
+
+ QCOMPARE(error.url(), QUrl());
+ QCOMPARE(error.line(), 3);
+ QCOMPARE(error.column(), 3);
+ QCOMPARE(error.description(), QString("Cannot assign to non-existent property \"foo\""));
+}
+
+// Test loading a file with syntax errors
+void tst_qdeclarativedom::loadSyntaxErrors()
+{
+ QByteArray qml = "import Qt 4.6\n"
+ "asdf";
+
+ QDeclarativeDomDocument document;
+ QVERIFY(false == document.load(&engine, qml));
+
+ QCOMPARE(document.errors().count(), 1);
+ QDeclarativeError error = document.errors().first();
+
+ QCOMPARE(error.url(), QUrl());
+ QCOMPARE(error.line(), 2);
+ QCOMPARE(error.column(), 1);
+ QCOMPARE(error.description(), QString("Syntax error"));
+}
+
+// Test attempting to load a file with remote references
+void tst_qdeclarativedom::loadRemoteErrors()
+{
+ QByteArray qml = "import Qt 4.6\n"
+ "Item {\n"
+ " Script {\n"
+ " source: \"http://localhost/exampleQmlScript.js\""
+ " }\n"
+ "}";
+ QDeclarativeDomDocument document;
+ QVERIFY(false == document.load(&engine, qml));
+
+ QCOMPARE(document.errors().count(), 1);
+ QDeclarativeError error = document.errors().first();
+
+ QCOMPARE(error.url(), QUrl());
+ QCOMPARE(error.line(), -1);
+ QCOMPARE(error.column(), -1);
+ QCOMPARE(error.description(), QString("QDeclarativeDomDocument supports local types only"));
+}
+
+// Test dynamic property declarations
+void tst_qdeclarativedom::loadDynamicProperty()
+{
+ {
+ QByteArray qml = "import Qt 4.6\n"
+ "Item {\n"
+ " property int a\n"
+ " property bool b\n"
+ " property double c\n"
+ " property real d\n"
+ " property string e\n"
+ " property url f\n"
+ " property color g\n"
+ " property date h\n"
+ " property var i\n"
+ " property variant j\n"
+ " property QtObject k\n"
+ "}";
+
+ QDeclarativeDomDocument document;
+ QVERIFY(document.load(&engine, qml));
+
+ QDeclarativeDomObject rootObject = document.rootObject();
+ QVERIFY(rootObject.isValid());
+
+ QCOMPARE(rootObject.dynamicProperties().count(), 11);
+
+#define DP_TEST(index, name, type, test_position, test_length, propTypeName) \
+ { \
+ QDeclarativeDomDynamicProperty d = rootObject.dynamicProperties().at(index); \
+ QVERIFY(d.isValid()); \
+ QVERIFY(d.propertyName() == # name ); \
+ QVERIFY(d.propertyType() == type); \
+ QVERIFY(d.propertyTypeName() == propTypeName); \
+ QVERIFY(d.isDefaultProperty() == false); \
+ QVERIFY(d.defaultValue().isValid() == false); \
+ QCOMPARE(d.position(), test_position); \
+ QCOMPARE(d.length(), test_length); \
+ } \
+
+ DP_TEST(0, a, QVariant::Int, 25, 14, "int");
+ DP_TEST(1, b, QVariant::Bool, 44, 15, "bool");
+ DP_TEST(2, c, QVariant::Double, 64, 17, "double");
+ DP_TEST(3, d, QMetaType::QReal, 86, 15, "real");
+ DP_TEST(4, e, QVariant::String, 106, 17, "string");
+ DP_TEST(5, f, QVariant::Url, 128, 14, "url");
+ DP_TEST(6, g, QVariant::Color, 147, 16, "color");
+ DP_TEST(7, h, QVariant::Date, 168, 15, "date");
+ DP_TEST(8, i, qMetaTypeId<QVariant>(), 188, 14, "var");
+ DP_TEST(9, j, qMetaTypeId<QVariant>(), 207, 18, "variant");
+ DP_TEST(10, k, -1, 230, 19, "QtObject");
+ }
+
+ {
+ QByteArray qml = "import Qt 4.6\n"
+ "Item {\n"
+ " property int a: 12\n"
+ " property int b: a + 6\n"
+ " default property QtObject c\n"
+ "}\n";
+
+ QDeclarativeDomDocument document;
+ QVERIFY(document.load(&engine, qml));
+
+ QDeclarativeDomObject rootObject = document.rootObject();
+ QVERIFY(rootObject.isValid());
+
+ QCOMPARE(rootObject.dynamicProperties().count(), 3);
+
+ {
+ QDeclarativeDomDynamicProperty d = rootObject.dynamicProperties().at(0);
+ QVERIFY(d.isDefaultProperty() == false);
+ QVERIFY(d.defaultValue().isValid());
+ QVERIFY(d.defaultValue().propertyName() == "a");
+ QVERIFY(d.defaultValue().value().isLiteral());
+ }
+
+ {
+ QDeclarativeDomDynamicProperty d = rootObject.dynamicProperties().at(1);
+ QVERIFY(d.isDefaultProperty() == false);
+ QVERIFY(d.defaultValue().isValid());
+ QVERIFY(d.defaultValue().propertyName() == "b");
+ QVERIFY(d.defaultValue().value().isBinding());
+ }
+
+ {
+ QDeclarativeDomDynamicProperty d = rootObject.dynamicProperties().at(2);
+ QVERIFY(d.isDefaultProperty() == true);
+ QVERIFY(d.defaultValue().isValid() == false);
+ }
+ }
+}
+
+// Test inline components
+void tst_qdeclarativedom::loadComponent()
+{
+ // Explicit component
+ {
+ QByteArray qml = "import Qt 4.6\n"
+ "Item {\n"
+ " Component {\n"
+ " id: myComponent\n"
+ " Item {}\n"
+ " }\n"
+ "}";
+
+ QDeclarativeDomDocument document;
+ QVERIFY(document.load(&engine, qml));
+
+ QDeclarativeDomObject rootItem = document.rootObject();
+ QVERIFY(rootItem.isValid());
+ QVERIFY(rootItem.properties().size() == 1);
+
+ QDeclarativeDomProperty listProperty = rootItem.properties().at(0);
+ QVERIFY(listProperty.isDefaultProperty());
+ QVERIFY(listProperty.value().isList());
+
+ QDeclarativeDomList list = listProperty.value().toList();
+ QVERIFY(list.values().size() == 1);
+
+ QDeclarativeDomObject componentObject = list.values().first().toObject();
+ QVERIFY(componentObject.isValid());
+ QVERIFY(componentObject.objectClassName() == "Component");
+ QVERIFY(componentObject.isComponent());
+
+ QDeclarativeDomComponent component = componentObject.toComponent();
+ QVERIFY(component.isValid());
+ QVERIFY(component.objectType() == "Qt/Component");
+ QVERIFY(component.objectTypeMajorVersion() == 4);
+ QVERIFY(component.objectTypeMinorVersion() == 6);
+ QVERIFY(component.objectClassName() == "Component");
+ QVERIFY(component.objectId() == "myComponent");
+ QVERIFY(component.properties().isEmpty());
+ QVERIFY(component.dynamicProperties().isEmpty());
+ QVERIFY(component.isCustomType() == false);
+ QVERIFY(component.customTypeData() == "");
+ QVERIFY(component.isComponent());
+ QCOMPARE(component.position(), 25);
+ QCOMPARE(component.length(), 57);
+
+ QVERIFY(component.componentRoot().isValid());
+ QVERIFY(component.componentRoot().objectClassName() == "Item");
+ }
+
+ // Implicit component
+ {
+ QByteArray qml = "import Qt 4.6\n"
+ "ListView {\n"
+ " delegate: Item {}\n"
+ "}";
+
+ QDeclarativeDomDocument document;
+ QVERIFY(document.load(&engine, qml));
+
+ QDeclarativeDomObject rootItem = document.rootObject();
+ QVERIFY(rootItem.isValid());
+ QVERIFY(rootItem.properties().size() == 1);
+
+ QDeclarativeDomProperty delegate = rootItem.property("delegate");
+
+ QDeclarativeDomObject componentObject = delegate.value().toObject();
+ QVERIFY(componentObject.isValid());
+ QVERIFY(componentObject.objectClassName() == "Component");
+ QVERIFY(componentObject.isComponent());
+
+ QDeclarativeDomComponent component = componentObject.toComponent();
+ QVERIFY(component.isValid());
+ QVERIFY(component.objectType() == "Qt/Component");
+ QVERIFY(component.objectClassName() == "Component");
+ QVERIFY(component.objectId() == "");
+ QVERIFY(component.properties().isEmpty());
+ QVERIFY(component.dynamicProperties().isEmpty());
+ QVERIFY(component.isCustomType() == false);
+ QVERIFY(component.customTypeData() == "");
+ QVERIFY(component.isComponent());
+ QCOMPARE(component.position(), 39);
+ QCOMPARE(component.length(), 7);
+
+ QVERIFY(component.componentRoot().isValid());
+ QVERIFY(component.componentRoot().objectClassName() == "Item");
+ }
+}
+
+// Test QDeclarativeDomObject::dynamicProperty() method
+void tst_qdeclarativedom::object_dynamicProperty()
+{
+ // Invalid object
+ {
+ QDeclarativeDomObject object;
+ QVERIFY(object.dynamicProperty("").isValid() == false);
+ QVERIFY(object.dynamicProperty("foo").isValid() == false);
+ }
+
+
+ // Valid object, no dynamic properties
+ {
+ QByteArray qml = "import Qt 4.6\n"
+ "Item {}";
+
+ QDeclarativeDomDocument document;
+ QVERIFY(document.load(&engine, qml));
+
+ QDeclarativeDomObject rootObject = document.rootObject();
+ QVERIFY(rootObject.isValid());
+
+ QVERIFY(rootObject.dynamicProperty("").isValid() == false);
+ QVERIFY(rootObject.dynamicProperty("foo").isValid() == false);
+ }
+
+ // Valid object, dynamic properties
+ {
+ QByteArray qml = "import Qt 4.6\n"
+ "Item {\n"
+ " property int a\n"
+ "}";
+
+ QDeclarativeDomDocument document;
+ QVERIFY(document.load(&engine, qml));
+
+ QDeclarativeDomObject rootObject = document.rootObject();
+ QVERIFY(rootObject.isValid());
+
+ QVERIFY(rootObject.dynamicProperty("").isValid() == false);
+ QVERIFY(rootObject.dynamicProperty("foo").isValid() == false);
+
+ QDeclarativeDomDynamicProperty p = rootObject.dynamicProperty("a");
+ QVERIFY(p.isValid());
+ QVERIFY(p.propertyName() == "a");
+ QVERIFY(p.propertyType() == QVariant::Int);
+ QVERIFY(p.propertyTypeName() == "int");
+ QVERIFY(p.isDefaultProperty() == false);
+ QCOMPARE(p.position(), 25);
+ QCOMPARE(p.length(), 14);
+ }
+
+}
+
+// Test QDeclarativeObject::property() method
+void tst_qdeclarativedom::object_property()
+{
+ // Invalid object
+ {
+ QDeclarativeDomObject object;
+ QVERIFY(object.property("").isValid() == false);
+ QVERIFY(object.property("foo").isValid() == false);
+ }
+
+ // Valid object - no default
+ {
+ QByteArray qml = "import Qt 4.6\n"
+ "Item {\n"
+ " x: 10\n"
+ " y: 12\n"
+ "}\n";
+
+ QDeclarativeDomDocument document;
+ QVERIFY(document.load(&engine, qml));
+
+ QDeclarativeDomObject rootObject = document.rootObject();
+ QVERIFY(rootObject.isValid());
+
+ QVERIFY(rootObject.property("").isValid() == false);
+ QVERIFY(rootObject.property("foo").isValid() == false);
+
+ QDeclarativeDomProperty x = rootObject.property("x");
+ QVERIFY(x.isValid());
+ QVERIFY(x.propertyName() == "x");
+ QVERIFY(x.propertyNameParts().count() == 1);
+ QVERIFY(x.propertyNameParts().at(0) == "x");
+ QVERIFY(x.isDefaultProperty() == false);
+ QVERIFY(x.value().isLiteral());
+ QVERIFY(x.value().toLiteral().literal() == "10");
+ QCOMPARE(x.position(), 25);
+ QCOMPARE(x.length(), 1);
+
+ QDeclarativeDomProperty y = rootObject.property("y");
+ QVERIFY(y.isValid());
+ QVERIFY(y.propertyName() == "y");
+ QVERIFY(y.propertyNameParts().count() == 1);
+ QVERIFY(y.propertyNameParts().at(0) == "y");
+ QVERIFY(y.isDefaultProperty() == false);
+ QVERIFY(y.value().isLiteral());
+ QVERIFY(y.value().toLiteral().literal() == "12");
+ QCOMPARE(y.position(), 35);
+ QCOMPARE(y.length(), 1);
+ }
+
+ // Valid object - with default
+ {
+ QByteArray qml = "import Qt 4.6\n"
+ "Item {\n"
+ " x: 10\n"
+ " y: 12\n"
+ " Item {}\n"
+ "}\n";
+
+ QDeclarativeDomDocument document;
+ QVERIFY(document.load(&engine, qml));
+
+ QDeclarativeDomObject rootObject = document.rootObject();
+ QVERIFY(rootObject.isValid());
+
+ QVERIFY(rootObject.property("").isValid() == false);
+ QVERIFY(rootObject.property("foo").isValid() == false);
+
+ QDeclarativeDomProperty x = rootObject.property("x");
+ QVERIFY(x.isValid());
+ QVERIFY(x.propertyName() == "x");
+ QVERIFY(x.propertyNameParts().count() == 1);
+ QVERIFY(x.propertyNameParts().at(0) == "x");
+ QVERIFY(x.isDefaultProperty() == false);
+ QVERIFY(x.value().isLiteral());
+ QVERIFY(x.value().toLiteral().literal() == "10");
+ QCOMPARE(x.position(), 25);
+ QCOMPARE(x.length(), 1);
+
+ QDeclarativeDomProperty y = rootObject.property("y");
+ QVERIFY(y.isValid());
+ QVERIFY(y.propertyName() == "y");
+ QVERIFY(y.propertyNameParts().count() == 1);
+ QVERIFY(y.propertyNameParts().at(0) == "y");
+ QVERIFY(y.isDefaultProperty() == false);
+ QVERIFY(y.value().isLiteral());
+ QVERIFY(y.value().toLiteral().literal() == "12");
+ QCOMPARE(y.position(), 35);
+ QCOMPARE(y.length(), 1);
+
+ QDeclarativeDomProperty data = rootObject.property("data");
+ QVERIFY(data.isValid());
+ QVERIFY(data.propertyName() == "data");
+ QVERIFY(data.propertyNameParts().count() == 1);
+ QVERIFY(data.propertyNameParts().at(0) == "data");
+ QVERIFY(data.isDefaultProperty() == true);
+ QVERIFY(data.value().isList());
+ QCOMPARE(data.position(), 45);
+ QCOMPARE(data.length(), 0);
+ }
+}
+
+// Tests the QDeclarativeDomObject::url() method
+void tst_qdeclarativedom::object_url()
+{
+ // Invalid object
+ {
+ QDeclarativeDomObject object;
+ QCOMPARE(object.url(), QUrl());
+ }
+
+ // Valid builtin object
+ {
+ QByteArray qml = "import Qt 4.6\n"
+ "Item {}";
+
+ QDeclarativeDomDocument document;
+ QVERIFY(document.load(&engine, qml));
+
+ QDeclarativeDomObject rootObject = document.rootObject();
+ QVERIFY(rootObject.isValid());
+ QCOMPARE(rootObject.url(), QUrl());
+ }
+
+ // Valid composite object
+ {
+ QByteArray qml = "import Qt 4.6\n"
+ "MyItem {}";
+
+ QUrl myUrl = QUrl::fromLocalFile(SRCDIR "/data/main.qml");
+ QUrl subUrl = QUrl::fromLocalFile(SRCDIR "/data/MyItem.qml");
+
+ QDeclarativeDomDocument document;
+ QVERIFY(document.load(&engine, qml, myUrl));
+
+ QDeclarativeDomObject rootObject = document.rootObject();
+ QVERIFY(rootObject.isValid());
+ QCOMPARE(rootObject.url(), subUrl);
+ }
+}
+
+// Test copy constructors and operators
+void tst_qdeclarativedom::copy()
+{
+ QByteArray qml = "import Qt 4.6\n"
+ "MyItem {\n"
+ " id: myItem\n"
+ " property int a: 10\n"
+ " x: 10\n"
+ " y: x + 10\n"
+ " z: NumberAnimation {}\n"
+ " opacity: Behavior {}\n"
+ " Component {\n"
+ " Item{}\n"
+ " }\n"
+ " children: [ Item{}, Item{} ]\n"
+ "}\n";
+
+ QUrl myUrl = QUrl::fromLocalFile(SRCDIR "/data/main.qml");
+
+ QDeclarativeDomDocument document;
+ QVERIFY(document.load(&engine, qml, myUrl));
+
+ // QDeclarativeDomDocument
+ {
+ QDeclarativeDomDocument document2(document);
+ QDeclarativeDomDocument document3;
+ document3 = document;
+
+ QCOMPARE(document.imports().count(), document2.imports().count());
+ QCOMPARE(document.errors().count(), document2.errors().count());
+ QCOMPARE(document.rootObject().objectClassName(), document2.rootObject().objectClassName());
+
+ QCOMPARE(document.imports().count(), document3.imports().count());
+ QCOMPARE(document.errors().count(), document3.errors().count());
+ QCOMPARE(document.rootObject().objectClassName(), document3.rootObject().objectClassName());
+ }
+
+ // QDeclarativeDomImport
+ {
+ QCOMPARE(document.imports().count(), 1);
+ QDeclarativeDomImport import = document.imports().at(0);
+
+ QDeclarativeDomImport import2(import);
+ QDeclarativeDomImport import3;
+ import3 = import2;
+
+ QCOMPARE(import.type(), import2.type());
+ QCOMPARE(import.uri(), import2.uri());
+ QCOMPARE(import.version(), import2.version());
+ QCOMPARE(import.qualifier(), import2.qualifier());
+
+ QCOMPARE(import.type(), import3.type());
+ QCOMPARE(import.uri(), import3.uri());
+ QCOMPARE(import.version(), import3.version());
+ QCOMPARE(import.qualifier(), import3.qualifier());
+ }
+
+ // QDeclarativeDomObject
+ {
+ QDeclarativeDomObject object = document.rootObject();
+ QVERIFY(object.isValid());
+
+ QDeclarativeDomObject object2(object);
+ QDeclarativeDomObject object3;
+ object3 = object;
+
+ QCOMPARE(object.isValid(), object2.isValid());
+ QCOMPARE(object.objectType(), object2.objectType());
+ QCOMPARE(object.objectClassName(), object2.objectClassName());
+ QCOMPARE(object.objectTypeMajorVersion(), object2.objectTypeMajorVersion());
+ QCOMPARE(object.objectTypeMinorVersion(), object2.objectTypeMinorVersion());
+ QCOMPARE(object.objectId(), object2.objectId());
+ QCOMPARE(object.properties().count(), object2.properties().count());
+ QCOMPARE(object.dynamicProperties().count(), object2.dynamicProperties().count());
+ QCOMPARE(object.isCustomType(), object2.isCustomType());
+ QCOMPARE(object.customTypeData(), object2.customTypeData());
+ QCOMPARE(object.isComponent(), object2.isComponent());
+ QCOMPARE(object.position(), object2.position());
+ QCOMPARE(object.length(), object2.length());
+ QCOMPARE(object.url(), object2.url());
+
+ QCOMPARE(object.isValid(), object3.isValid());
+ QCOMPARE(object.objectType(), object3.objectType());
+ QCOMPARE(object.objectClassName(), object3.objectClassName());
+ QCOMPARE(object.objectTypeMajorVersion(), object3.objectTypeMajorVersion());
+ QCOMPARE(object.objectTypeMinorVersion(), object3.objectTypeMinorVersion());
+ QCOMPARE(object.objectId(), object3.objectId());
+ QCOMPARE(object.properties().count(), object3.properties().count());
+ QCOMPARE(object.dynamicProperties().count(), object3.dynamicProperties().count());
+ QCOMPARE(object.isCustomType(), object3.isCustomType());
+ QCOMPARE(object.customTypeData(), object3.customTypeData());
+ QCOMPARE(object.isComponent(), object3.isComponent());
+ QCOMPARE(object.position(), object3.position());
+ QCOMPARE(object.length(), object3.length());
+ QCOMPARE(object.url(), object3.url());
+ }
+
+ // QDeclarativeDomDynamicProperty
+ {
+ QDeclarativeDomObject object = document.rootObject();
+ QDeclarativeDomDynamicProperty property = object.dynamicProperty("a");
+
+ QDeclarativeDomDynamicProperty property2(property);
+ QDeclarativeDomDynamicProperty property3;
+ property3 = property;
+
+ QCOMPARE(property.isValid(), property2.isValid());
+ QCOMPARE(property.propertyName(), property2.propertyName());
+ QCOMPARE(property.propertyType(), property2.propertyType());
+ QCOMPARE(property.propertyTypeName(), property2.propertyTypeName());
+ QCOMPARE(property.isDefaultProperty(), property2.isDefaultProperty());
+ QCOMPARE(property.defaultValue().propertyName(), property2.defaultValue().propertyName());
+ QCOMPARE(property.position(), property2.position());
+ QCOMPARE(property.length(), property2.length());
+
+ QCOMPARE(property.isValid(), property3.isValid());
+ QCOMPARE(property.propertyName(), property3.propertyName());
+ QCOMPARE(property.propertyType(), property3.propertyType());
+ QCOMPARE(property.propertyTypeName(), property3.propertyTypeName());
+ QCOMPARE(property.isDefaultProperty(), property3.isDefaultProperty());
+ QCOMPARE(property.defaultValue().propertyName(), property3.defaultValue().propertyName());
+ QCOMPARE(property.position(), property3.position());
+ QCOMPARE(property.length(), property3.length());
+ }
+
+ // QDeclarativeDomProperty
+ {
+ QDeclarativeDomObject object = document.rootObject();
+ QDeclarativeDomProperty property = object.property("opacity");
+
+ QDeclarativeDomProperty property2(property);
+ QDeclarativeDomProperty property3;
+ property3 = property;
+
+ QCOMPARE(property.isValid(), property2.isValid());
+ QCOMPARE(property.propertyName(), property2.propertyName());
+ QCOMPARE(property.propertyNameParts(), property2.propertyNameParts());
+ QCOMPARE(property.isDefaultProperty(), property2.isDefaultProperty());
+ QCOMPARE(property.value().type(), property2.value().type());
+ QCOMPARE(property.position(), property2.position());
+ QCOMPARE(property.length(), property2.length());
+
+ QCOMPARE(property.isValid(), property3.isValid());
+ QCOMPARE(property.propertyName(), property3.propertyName());
+ QCOMPARE(property.propertyNameParts(), property3.propertyNameParts());
+ QCOMPARE(property.isDefaultProperty(), property3.isDefaultProperty());
+ QCOMPARE(property.value().type(), property3.value().type());
+ QCOMPARE(property.position(), property3.position());
+ QCOMPARE(property.length(), property3.length());
+ }
+
+ // QDeclarativeDomValueLiteral
+ {
+ QDeclarativeDomObject object = document.rootObject();
+ QDeclarativeDomProperty property = object.property("x");
+ QDeclarativeDomValueLiteral literal = property.value().toLiteral();
+ QCOMPARE(literal.literal(), QString("10"));
+
+ QDeclarativeDomValueLiteral literal2(literal);
+ QDeclarativeDomValueLiteral literal3;
+ literal3 = literal2;
+
+ QCOMPARE(literal2.literal(), QString("10"));
+ QCOMPARE(literal3.literal(), QString("10"));
+ }
+
+
+ // QDeclarativeDomValueBinding
+ {
+ QDeclarativeDomObject object = document.rootObject();
+ QDeclarativeDomProperty property = object.property("y");
+ QDeclarativeDomValueBinding binding = property.value().toBinding();
+ QCOMPARE(binding.binding(), QString("x + 10"));
+
+ QDeclarativeDomValueBinding binding2(binding);
+ QDeclarativeDomValueBinding binding3;
+ binding3 = binding2;
+
+ QCOMPARE(binding2.binding(), QString("x + 10"));
+ QCOMPARE(binding3.binding(), QString("x + 10"));
+ }
+
+ // QDeclarativeDomValueValueSource
+ {
+ QDeclarativeDomObject object = document.rootObject();
+ QDeclarativeDomProperty property = object.property("z");
+ QDeclarativeDomValueValueSource source = property.value().toValueSource();
+ QCOMPARE(source.object().objectClassName(), QByteArray("NumberAnimation"));
+
+ QDeclarativeDomValueValueSource source2(source);
+ QDeclarativeDomValueValueSource source3;
+ source3 = source;
+
+ QCOMPARE(source2.object().objectClassName(), QByteArray("NumberAnimation"));
+ QCOMPARE(source3.object().objectClassName(), QByteArray("NumberAnimation"));
+ }
+
+ // QDeclarativeDomValueValueInterceptor
+ {
+ QDeclarativeDomObject object = document.rootObject();
+ QDeclarativeDomProperty property = object.property("opacity");
+ QDeclarativeDomValueValueInterceptor interceptor = property.value().toValueInterceptor();
+ QCOMPARE(interceptor.object().objectClassName(), QByteArray("Behavior"));
+
+ QDeclarativeDomValueValueInterceptor interceptor2(interceptor);
+ QDeclarativeDomValueValueInterceptor interceptor3;
+ interceptor3 = interceptor;
+
+ QCOMPARE(interceptor2.object().objectClassName(), QByteArray("Behavior"));
+ QCOMPARE(interceptor3.object().objectClassName(), QByteArray("Behavior"));
+ }
+
+ // QDeclarativeDomComponent
+ {
+ QDeclarativeDomObject object = document.rootObject();
+ QDeclarativeDomProperty property = object.property("data");
+ QCOMPARE(property.value().toList().values().count(), 1);
+ QDeclarativeDomComponent component =
+ property.value().toList().values().at(0).toObject().toComponent();
+ QCOMPARE(component.componentRoot().objectClassName(), QByteArray("Item"));
+
+ QDeclarativeDomComponent component2(component);
+ QDeclarativeDomComponent component3;
+ component3 = component;
+
+ QCOMPARE(component.componentRoot().objectClassName(), component2.componentRoot().objectClassName());
+ QCOMPARE(component.isValid(), component2.isValid());
+ QCOMPARE(component.objectType(), component2.objectType());
+ QCOMPARE(component.objectClassName(), component2.objectClassName());
+ QCOMPARE(component.objectTypeMajorVersion(), component2.objectTypeMajorVersion());
+ QCOMPARE(component.objectTypeMinorVersion(), component2.objectTypeMinorVersion());
+ QCOMPARE(component.objectId(), component2.objectId());
+ QCOMPARE(component.properties().count(), component2.properties().count());
+ QCOMPARE(component.dynamicProperties().count(), component2.dynamicProperties().count());
+ QCOMPARE(component.isCustomType(), component2.isCustomType());
+ QCOMPARE(component.customTypeData(), component2.customTypeData());
+ QCOMPARE(component.isComponent(), component2.isComponent());
+ QCOMPARE(component.position(), component2.position());
+ QCOMPARE(component.length(), component2.length());
+ QCOMPARE(component.url(), component2.url());
+
+ QCOMPARE(component.componentRoot().objectClassName(), component3.componentRoot().objectClassName());
+ QCOMPARE(component.isValid(), component3.isValid());
+ QCOMPARE(component.objectType(), component3.objectType());
+ QCOMPARE(component.objectClassName(), component3.objectClassName());
+ QCOMPARE(component.objectTypeMajorVersion(), component3.objectTypeMajorVersion());
+ QCOMPARE(component.objectTypeMinorVersion(), component3.objectTypeMinorVersion());
+ QCOMPARE(component.objectId(), component3.objectId());
+ QCOMPARE(component.properties().count(), component3.properties().count());
+ QCOMPARE(component.dynamicProperties().count(), component3.dynamicProperties().count());
+ QCOMPARE(component.isCustomType(), component3.isCustomType());
+ QCOMPARE(component.customTypeData(), component3.customTypeData());
+ QCOMPARE(component.isComponent(), component3.isComponent());
+ QCOMPARE(component.position(), component3.position());
+ QCOMPARE(component.length(), component3.length());
+ QCOMPARE(component.url(), component3.url());
+ }
+
+ // QDeclarativeDomValue
+ {
+ QDeclarativeDomObject object = document.rootObject();
+ QDeclarativeDomProperty property = object.property("data");
+ QDeclarativeDomValue value = property.value();
+
+ QDeclarativeDomValue value2(value);
+ QDeclarativeDomValue value3;
+ value3 = value;
+
+ QCOMPARE(value.type(), value2.type());
+ QCOMPARE(value.isInvalid(), value2.isInvalid());
+ QCOMPARE(value.isLiteral(), value2.isLiteral());
+ QCOMPARE(value.isBinding(), value2.isBinding());
+ QCOMPARE(value.isValueSource(), value2.isValueSource());
+ QCOMPARE(value.isValueInterceptor(), value2.isValueInterceptor());
+ QCOMPARE(value.isObject(), value2.isObject());
+ QCOMPARE(value.isList(), value2.isList());
+ QCOMPARE(value.position(), value2.position());
+ QCOMPARE(value.length(), value2.length());
+
+ QCOMPARE(value.type(), value3.type());
+ QCOMPARE(value.isInvalid(), value3.isInvalid());
+ QCOMPARE(value.isLiteral(), value3.isLiteral());
+ QCOMPARE(value.isBinding(), value3.isBinding());
+ QCOMPARE(value.isValueSource(), value3.isValueSource());
+ QCOMPARE(value.isValueInterceptor(), value3.isValueInterceptor());
+ QCOMPARE(value.isObject(), value3.isObject());
+ QCOMPARE(value.isList(), value3.isList());
+ QCOMPARE(value.position(), value3.position());
+ QCOMPARE(value.length(), value3.length());
+ }
+ {
+ QDeclarativeDomObject object = document.rootObject();
+ QDeclarativeDomProperty property = object.property("x");
+ QDeclarativeDomValue value = property.value();
+
+ QDeclarativeDomValue value2(value);
+ QDeclarativeDomValue value3;
+ value3 = value;
+
+ QCOMPARE(value.type(), value2.type());
+ QCOMPARE(value.isInvalid(), value2.isInvalid());
+ QCOMPARE(value.isLiteral(), value2.isLiteral());
+ QCOMPARE(value.isBinding(), value2.isBinding());
+ QCOMPARE(value.isValueSource(), value2.isValueSource());
+ QCOMPARE(value.isValueInterceptor(), value2.isValueInterceptor());
+ QCOMPARE(value.isObject(), value2.isObject());
+ QCOMPARE(value.isList(), value2.isList());
+ QCOMPARE(value.position(), value2.position());
+ QCOMPARE(value.length(), value2.length());
+
+ QCOMPARE(value.type(), value3.type());
+ QCOMPARE(value.isInvalid(), value3.isInvalid());
+ QCOMPARE(value.isLiteral(), value3.isLiteral());
+ QCOMPARE(value.isBinding(), value3.isBinding());
+ QCOMPARE(value.isValueSource(), value3.isValueSource());
+ QCOMPARE(value.isValueInterceptor(), value3.isValueInterceptor());
+ QCOMPARE(value.isObject(), value3.isObject());
+ QCOMPARE(value.isList(), value3.isList());
+ QCOMPARE(value.position(), value3.position());
+ QCOMPARE(value.length(), value3.length());
+ }
+ {
+ QDeclarativeDomValue value;
+
+ QDeclarativeDomValue value2(value);
+ QDeclarativeDomValue value3;
+ value3 = value;
+
+ QCOMPARE(value.type(), value2.type());
+ QCOMPARE(value.isInvalid(), value2.isInvalid());
+ QCOMPARE(value.isLiteral(), value2.isLiteral());
+ QCOMPARE(value.isBinding(), value2.isBinding());
+ QCOMPARE(value.isValueSource(), value2.isValueSource());
+ QCOMPARE(value.isValueInterceptor(), value2.isValueInterceptor());
+ QCOMPARE(value.isObject(), value2.isObject());
+ QCOMPARE(value.isList(), value2.isList());
+ QCOMPARE(value.position(), value2.position());
+ QCOMPARE(value.length(), value2.length());
+
+ QCOMPARE(value.type(), value3.type());
+ QCOMPARE(value.isInvalid(), value3.isInvalid());
+ QCOMPARE(value.isLiteral(), value3.isLiteral());
+ QCOMPARE(value.isBinding(), value3.isBinding());
+ QCOMPARE(value.isValueSource(), value3.isValueSource());
+ QCOMPARE(value.isValueInterceptor(), value3.isValueInterceptor());
+ QCOMPARE(value.isObject(), value3.isObject());
+ QCOMPARE(value.isList(), value3.isList());
+ QCOMPARE(value.position(), value3.position());
+ QCOMPARE(value.length(), value3.length());
+ }
+
+ // QDeclarativeDomList
+ {
+ QDeclarativeDomObject object = document.rootObject();
+ QDeclarativeDomProperty property = object.property("children");
+ QDeclarativeDomList list = property.value().toList();
+ QCOMPARE(list.values().count(), 2);
+
+ QDeclarativeDomList list2(list);
+ QDeclarativeDomList list3;
+ list3 = list2;
+
+ QCOMPARE(list.values().count(), list2.values().count());
+ QCOMPARE(list.position(), list2.position());
+ QCOMPARE(list.length(), list2.length());
+ QCOMPARE(list.commaPositions(), list2.commaPositions());
+
+ QCOMPARE(list.values().count(), list3.values().count());
+ QCOMPARE(list.position(), list3.position());
+ QCOMPARE(list.length(), list3.length());
+ QCOMPARE(list.commaPositions(), list3.commaPositions());
+
+ }
+}
+
+// Tests the position/length of various elements
+void tst_qdeclarativedom::position()
+{
+ QByteArray qml = "import Qt 4.6\n"
+ /*14*/ "Item {\n"
+ /*21*/ " id: myItem\n"
+ /*36*/ " property int a: 10\n"
+ /*59*/ " x: 10\n"
+ /*69*/ " y: x + 10\n"
+ /*83*/ " z: NumberAnimation {}\n"
+ /*109*/ " opacity: Behavior {}\n"
+ /*134*/ " Component {\n"
+ /*150*/ " Item{}\n"
+ /*165*/ " }\n"
+ /*171*/ " children: [ Item{}, Item{} ]\n"
+ /*204*/ "}\n";
+
+
+ QDeclarativeDomDocument document;
+ QVERIFY(document.load(&engine, qml));
+
+ QDeclarativeDomObject root = document.rootObject();
+
+ // All QDeclarativeDomDynamicProperty
+ QDeclarativeDomDynamicProperty dynProp = root.dynamicProperty("a");
+ QCOMPARE(dynProp.position(), 40);
+ QCOMPARE(dynProp.length(), 18);
+
+ // All QDeclarativeDomProperty
+ QDeclarativeDomProperty x = root.property("x");
+ QCOMPARE(x.position(), 63);
+ QCOMPARE(x.length(), 1);
+
+ QDeclarativeDomProperty y = root.property("y");
+ QCOMPARE(y.position(), 73);
+ QCOMPARE(y.length(), 1);
+
+ QDeclarativeDomProperty z = root.property("z");
+ QCOMPARE(z.position(), 87);
+ QCOMPARE(z.length(), 1);
+
+ QDeclarativeDomProperty opacity = root.property("opacity");
+ QCOMPARE(opacity.position(), 113);
+ QCOMPARE(opacity.length(), 7);
+
+ QDeclarativeDomProperty data = root.property("data");
+ QCOMPARE(data.position(), 138);
+ QCOMPARE(data.length(), 0);
+
+ QDeclarativeDomProperty children = root.property("children");
+ QCOMPARE(children.position(), 175);
+ QCOMPARE(children.length(), 8);
+
+ QDeclarativeDomList dataList = data.value().toList();
+ QCOMPARE(dataList.values().count(), 1);
+ QDeclarativeDomList childrenList = children.value().toList();
+ QCOMPARE(childrenList.values().count(), 2);
+
+ // All QDeclarativeDomObject
+ QCOMPARE(root.position(), 14);
+ QCOMPARE(root.length(), 191);
+
+ QDeclarativeDomObject numberAnimation = z.value().toValueSource().object();
+ QCOMPARE(numberAnimation.position(), 90);
+ QCOMPARE(numberAnimation.length(), 18);
+
+ QDeclarativeDomObject behavior = opacity.value().toValueInterceptor().object();
+ QCOMPARE(behavior.position(), 122);
+ QCOMPARE(behavior.length(), 11);
+
+ QDeclarativeDomObject component = dataList.values().at(0).toObject();
+ QCOMPARE(component.position(), 138);
+ QCOMPARE(component.length(), 32);
+
+ QDeclarativeDomObject componentRoot = component.toComponent().componentRoot();
+ QCOMPARE(componentRoot.position(), 158);
+ QCOMPARE(componentRoot.length(), 6);
+
+ QDeclarativeDomObject child1 = childrenList.values().at(0).toObject();
+ QCOMPARE(child1.position(), 187);
+ QCOMPARE(child1.length(), 6);
+
+ QDeclarativeDomObject child2 = childrenList.values().at(1).toObject();
+ QCOMPARE(child2.position(), 195);
+ QCOMPARE(child2.length(), 6);
+
+ // All QDeclarativeDomValue
+ QDeclarativeDomValue xValue = x.value();
+ QCOMPARE(xValue.position(), 66);
+ QCOMPARE(xValue.length(), 2);
+
+ QDeclarativeDomValue yValue = y.value();
+ QCOMPARE(yValue.position(), 76);
+ QCOMPARE(yValue.length(), 6);
+
+ QDeclarativeDomValue zValue = z.value();
+ QCOMPARE(zValue.position(), 90);
+ QCOMPARE(zValue.length(), 18);
+
+ QDeclarativeDomValue opacityValue = opacity.value();
+ QCOMPARE(opacityValue.position(), 122);
+ QCOMPARE(opacityValue.length(), 11);
+
+ QDeclarativeDomValue dataValue = data.value();
+ QCOMPARE(dataValue.position(), 138);
+ QCOMPARE(dataValue.length(), 32);
+
+ QDeclarativeDomValue child1Value = childrenList.values().at(0);
+ QCOMPARE(child1Value.position(), 187);
+ QCOMPARE(child1Value.length(), 6);
+
+ QDeclarativeDomValue child2Value = childrenList.values().at(1);
+ QCOMPARE(child2Value.position(), 195);
+ QCOMPARE(child2Value.length(), 6);
+
+ // All QDeclarativeDomList
+ qWarning("QDeclarativeListValue position test required");
+}
+
+QTEST_MAIN(tst_qdeclarativedom)
+
+#include "tst_qdeclarativedom.moc"
diff --git a/tests/auto/declarative/qmleasefollow/data/easefollow1.qml b/tests/auto/declarative/qdeclarativeeasefollow/data/easefollow1.qml
index 0cc19eb..0cc19eb 100644
--- a/tests/auto/declarative/qmleasefollow/data/easefollow1.qml
+++ b/tests/auto/declarative/qdeclarativeeasefollow/data/easefollow1.qml
diff --git a/tests/auto/declarative/qmleasefollow/data/easefollow2.qml b/tests/auto/declarative/qdeclarativeeasefollow/data/easefollow2.qml
index b65964e..b65964e 100644
--- a/tests/auto/declarative/qmleasefollow/data/easefollow2.qml
+++ b/tests/auto/declarative/qdeclarativeeasefollow/data/easefollow2.qml
diff --git a/tests/auto/declarative/qmleasefollow/data/easefollow3.qml b/tests/auto/declarative/qdeclarativeeasefollow/data/easefollow3.qml
index f8886e9..f8886e9 100644
--- a/tests/auto/declarative/qmleasefollow/data/easefollow3.qml
+++ b/tests/auto/declarative/qdeclarativeeasefollow/data/easefollow3.qml
diff --git a/tests/auto/declarative/qdeclarativeeasefollow/qdeclarativeeasefollow.pro b/tests/auto/declarative/qdeclarativeeasefollow/qdeclarativeeasefollow.pro
new file mode 100644
index 0000000..71df4f4
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeeasefollow/qdeclarativeeasefollow.pro
@@ -0,0 +1,8 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative gui
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qdeclarativeeasefollow.cpp
+
+# Define SRCDIR equal to test's source directory
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qdeclarativeeasefollow/tst_qdeclarativeeasefollow.cpp b/tests/auto/declarative/qdeclarativeeasefollow/tst_qdeclarativeeasefollow.cpp
new file mode 100644
index 0000000..036eec0
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeeasefollow/tst_qdeclarativeeasefollow.cpp
@@ -0,0 +1,122 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QtDeclarative/qdeclarativeengine.h>
+#include <QtDeclarative/qdeclarativecomponent.h>
+#include <private/qdeclarativeeasefollow_p.h>
+#include <private/qdeclarativevaluetype_p.h>
+#include "../../../shared/util.h"
+
+class tst_qdeclarativeeasefollow : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qdeclarativeeasefollow();
+
+private slots:
+ void defaultValues();
+ void values();
+ void disabled();
+
+private:
+ QDeclarativeEngine engine;
+};
+
+tst_qdeclarativeeasefollow::tst_qdeclarativeeasefollow()
+{
+}
+
+void tst_qdeclarativeeasefollow::defaultValues()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/easefollow1.qml"));
+ QDeclarativeEaseFollow *obj = qobject_cast<QDeclarativeEaseFollow*>(c.create());
+
+ QVERIFY(obj != 0);
+
+ QCOMPARE(obj->sourceValue(), 0.);
+ QCOMPARE(obj->velocity(), 200.);
+ QCOMPARE(obj->enabled(), true);
+ QCOMPARE(obj->duration(), -1.);
+ QCOMPARE(obj->maximumEasingTime(), -1.);
+ QCOMPARE(obj->reversingMode(), QDeclarativeEaseFollow::Eased);
+
+ delete obj;
+}
+
+void tst_qdeclarativeeasefollow::values()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/easefollow2.qml"));
+ QDeclarativeEaseFollow *obj = qobject_cast<QDeclarativeEaseFollow*>(c.create());
+
+ QVERIFY(obj != 0);
+
+ QCOMPARE(obj->sourceValue(), 10.);
+ QCOMPARE(obj->velocity(), 200.);
+ QCOMPARE(obj->enabled(), true);
+ QCOMPARE(obj->duration(), 300.);
+ QCOMPARE(obj->maximumEasingTime(), -1.);
+ QCOMPARE(obj->reversingMode(), QDeclarativeEaseFollow::Immediate);
+
+ delete obj;
+}
+
+void tst_qdeclarativeeasefollow::disabled()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/easefollow3.qml"));
+ QDeclarativeEaseFollow *obj = qobject_cast<QDeclarativeEaseFollow*>(c.create());
+
+ QVERIFY(obj != 0);
+
+ QCOMPARE(obj->sourceValue(), 10.);
+ QCOMPARE(obj->velocity(), 250.);
+ QCOMPARE(obj->enabled(), false);
+ QCOMPARE(obj->maximumEasingTime(), 150.);
+ QCOMPARE(obj->reversingMode(), QDeclarativeEaseFollow::Sync);
+
+ delete obj;
+}
+
+QTEST_MAIN(tst_qdeclarativeeasefollow)
+
+#include "tst_qdeclarativeeasefollow.moc"
diff --git a/tests/auto/declarative/qmlecmascript/data/ConstantsOverrideBindings.qml b/tests/auto/declarative/qdeclarativeecmascript/data/ConstantsOverrideBindings.qml
index b4a702b..b4a702b 100644
--- a/tests/auto/declarative/qmlecmascript/data/ConstantsOverrideBindings.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/ConstantsOverrideBindings.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/CustomObject.qml b/tests/auto/declarative/qdeclarativeecmascript/data/CustomObject.qml
index 691d9ec..691d9ec 100644
--- a/tests/auto/declarative/qmlecmascript/data/CustomObject.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/CustomObject.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/MethodsObject.qml b/tests/auto/declarative/qdeclarativeecmascript/data/MethodsObject.qml
index f51ca86..f51ca86 100644
--- a/tests/auto/declarative/qmlecmascript/data/MethodsObject.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/MethodsObject.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/NestedTypeTransientErrors.qml b/tests/auto/declarative/qdeclarativeecmascript/data/NestedTypeTransientErrors.qml
index 7c32e56..7c32e56 100644
--- a/tests/auto/declarative/qmlecmascript/data/NestedTypeTransientErrors.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/NestedTypeTransientErrors.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/ScopeObject.qml b/tests/auto/declarative/qdeclarativeecmascript/data/ScopeObject.qml
index b7bec63..b7bec63 100644
--- a/tests/auto/declarative/qmlecmascript/data/ScopeObject.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/ScopeObject.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/TypeForDynamicCreation.qml b/tests/auto/declarative/qdeclarativeecmascript/data/TypeForDynamicCreation.qml
index 56e0625..56e0625 100644
--- a/tests/auto/declarative/qmlecmascript/data/TypeForDynamicCreation.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/TypeForDynamicCreation.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/aliasPropertyAndBinding.qml b/tests/auto/declarative/qdeclarativeecmascript/data/aliasPropertyAndBinding.qml
index 5c3ea1f..5c3ea1f 100644
--- a/tests/auto/declarative/qmlecmascript/data/aliasPropertyAndBinding.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/aliasPropertyAndBinding.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/assignBasicTypes.2.qml b/tests/auto/declarative/qdeclarativeecmascript/data/assignBasicTypes.2.qml
index db7f2b5..db7f2b5 100644
--- a/tests/auto/declarative/qmlecmascript/data/assignBasicTypes.2.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/assignBasicTypes.2.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/assignBasicTypes.qml b/tests/auto/declarative/qdeclarativeecmascript/data/assignBasicTypes.qml
index 128db69..128db69 100644
--- a/tests/auto/declarative/qmlecmascript/data/assignBasicTypes.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/assignBasicTypes.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/attachedProperty.qml b/tests/auto/declarative/qdeclarativeecmascript/data/attachedProperty.qml
index 061eda0..061eda0 100644
--- a/tests/auto/declarative/qmlecmascript/data/attachedProperty.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/attachedProperty.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/bindingLoop.qml b/tests/auto/declarative/qdeclarativeecmascript/data/bindingLoop.qml
index 80545cf..80545cf 100644
--- a/tests/auto/declarative/qmlecmascript/data/bindingLoop.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/bindingLoop.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/boolPropertiesEvaluateAsBool.1.qml b/tests/auto/declarative/qdeclarativeecmascript/data/boolPropertiesEvaluateAsBool.1.qml
index 3147f63..3147f63 100644
--- a/tests/auto/declarative/qmlecmascript/data/boolPropertiesEvaluateAsBool.1.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/boolPropertiesEvaluateAsBool.1.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/boolPropertiesEvaluateAsBool.2.qml b/tests/auto/declarative/qdeclarativeecmascript/data/boolPropertiesEvaluateAsBool.2.qml
index c89bb49..c89bb49 100644
--- a/tests/auto/declarative/qmlecmascript/data/boolPropertiesEvaluateAsBool.2.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/boolPropertiesEvaluateAsBool.2.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/bug.1.qml b/tests/auto/declarative/qdeclarativeecmascript/data/bug.1.qml
index 266de76..266de76 100644
--- a/tests/auto/declarative/qmlecmascript/data/bug.1.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/bug.1.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/compositePropertyType.qml b/tests/auto/declarative/qdeclarativeecmascript/data/compositePropertyType.qml
index 80a2814..80a2814 100644
--- a/tests/auto/declarative/qmlecmascript/data/compositePropertyType.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/compositePropertyType.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/constantsOverrideBindings.1.qml b/tests/auto/declarative/qdeclarativeecmascript/data/constantsOverrideBindings.1.qml
index 13c5ae5..13c5ae5 100644
--- a/tests/auto/declarative/qmlecmascript/data/constantsOverrideBindings.1.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/constantsOverrideBindings.1.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/constantsOverrideBindings.2.qml b/tests/auto/declarative/qdeclarativeecmascript/data/constantsOverrideBindings.2.qml
index 207a06b..207a06b 100644
--- a/tests/auto/declarative/qmlecmascript/data/constantsOverrideBindings.2.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/constantsOverrideBindings.2.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/constantsOverrideBindings.3.qml b/tests/auto/declarative/qdeclarativeecmascript/data/constantsOverrideBindings.3.qml
index ca9d1d8..ca9d1d8 100644
--- a/tests/auto/declarative/qmlecmascript/data/constantsOverrideBindings.3.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/constantsOverrideBindings.3.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/qmlToString.qml b/tests/auto/declarative/qdeclarativeecmascript/data/declarativeToString.qml
index ac296ce..ac296ce 100644
--- a/tests/auto/declarative/qmlecmascript/data/qmlToString.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/declarativeToString.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/deferredProperties.qml b/tests/auto/declarative/qdeclarativeecmascript/data/deferredProperties.qml
index e01f708..e01f708 100644
--- a/tests/auto/declarative/qmlecmascript/data/deferredProperties.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/deferredProperties.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/deletedObject.qml b/tests/auto/declarative/qdeclarativeecmascript/data/deletedObject.qml
index 6bc3a17..6bc3a17 100644
--- a/tests/auto/declarative/qmlecmascript/data/deletedObject.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/deletedObject.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/dynamicCreation.helper.qml b/tests/auto/declarative/qdeclarativeecmascript/data/dynamicCreation.helper.qml
index d790d63..d790d63 100644
--- a/tests/auto/declarative/qmlecmascript/data/dynamicCreation.helper.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/dynamicCreation.helper.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/dynamicCreation.qml b/tests/auto/declarative/qdeclarativeecmascript/data/dynamicCreation.qml
index ed5e571..ed5e571 100644
--- a/tests/auto/declarative/qmlecmascript/data/dynamicCreation.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/dynamicCreation.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/dynamicDeletion.qml b/tests/auto/declarative/qdeclarativeecmascript/data/dynamicDeletion.qml
index 0855b29..0855b29 100644
--- a/tests/auto/declarative/qmlecmascript/data/dynamicDeletion.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/dynamicDeletion.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/enums.1.qml b/tests/auto/declarative/qdeclarativeecmascript/data/enums.1.qml
index 6351823..6351823 100644
--- a/tests/auto/declarative/qmlecmascript/data/enums.1.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/enums.1.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/enums.2.qml b/tests/auto/declarative/qdeclarativeecmascript/data/enums.2.qml
index bdc672f..bdc672f 100644
--- a/tests/auto/declarative/qmlecmascript/data/enums.2.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/enums.2.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/exceptionClearsOnReeval.qml b/tests/auto/declarative/qdeclarativeecmascript/data/exceptionClearsOnReeval.qml
index a2f0d1a..a2f0d1a 100644
--- a/tests/auto/declarative/qmlecmascript/data/exceptionClearsOnReeval.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/exceptionClearsOnReeval.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/exceptionProducesWarning.qml b/tests/auto/declarative/qdeclarativeecmascript/data/exceptionProducesWarning.qml
index acc3163..acc3163 100644
--- a/tests/auto/declarative/qmlecmascript/data/exceptionProducesWarning.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/exceptionProducesWarning.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/exceptionProducesWarning2.qml b/tests/auto/declarative/qdeclarativeecmascript/data/exceptionProducesWarning2.qml
index 44e10c1..44e10c1 100644
--- a/tests/auto/declarative/qmlecmascript/data/exceptionProducesWarning2.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/exceptionProducesWarning2.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/extendedObjectPropertyLookup.qml b/tests/auto/declarative/qdeclarativeecmascript/data/extendedObjectPropertyLookup.qml
index 9a82ad1..9a82ad1 100644
--- a/tests/auto/declarative/qmlecmascript/data/extendedObjectPropertyLookup.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/extendedObjectPropertyLookup.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/extensionObjects.qml b/tests/auto/declarative/qdeclarativeecmascript/data/extensionObjects.qml
index a902312..a902312 100644
--- a/tests/auto/declarative/qmlecmascript/data/extensionObjects.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/extensionObjects.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/externalScript.1.qml b/tests/auto/declarative/qdeclarativeecmascript/data/externalScript.1.qml
index 2ac7b6e..2ac7b6e 100644
--- a/tests/auto/declarative/qmlecmascript/data/externalScript.1.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/externalScript.1.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/externalScript.2.js b/tests/auto/declarative/qdeclarativeecmascript/data/externalScript.2.js
index 78c3a86..78c3a86 100644
--- a/tests/auto/declarative/qmlecmascript/data/externalScript.2.js
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/externalScript.2.js
diff --git a/tests/auto/declarative/qmlecmascript/data/externalScript.2.qml b/tests/auto/declarative/qdeclarativeecmascript/data/externalScript.2.qml
index dec657c..dec657c 100644
--- a/tests/auto/declarative/qmlecmascript/data/externalScript.2.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/externalScript.2.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/externalScript.3.qml b/tests/auto/declarative/qdeclarativeecmascript/data/externalScript.3.qml
index d7acf38..d7acf38 100644
--- a/tests/auto/declarative/qmlecmascript/data/externalScript.3.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/externalScript.3.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/externalScript.4.qml b/tests/auto/declarative/qdeclarativeecmascript/data/externalScript.4.qml
index 16211aa..16211aa 100644
--- a/tests/auto/declarative/qmlecmascript/data/externalScript.4.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/externalScript.4.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/externalScript.js b/tests/auto/declarative/qdeclarativeecmascript/data/externalScript.js
index 8928652..8928652 100644
--- a/tests/auto/declarative/qmlecmascript/data/externalScript.js
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/externalScript.js
diff --git a/tests/auto/declarative/qmlecmascript/data/idShortcutInvalidates.1.qml b/tests/auto/declarative/qdeclarativeecmascript/data/idShortcutInvalidates.1.qml
index 2db0fc6..2db0fc6 100644
--- a/tests/auto/declarative/qmlecmascript/data/idShortcutInvalidates.1.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/idShortcutInvalidates.1.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/idShortcutInvalidates.qml b/tests/auto/declarative/qdeclarativeecmascript/data/idShortcutInvalidates.qml
index f66428d..f66428d 100644
--- a/tests/auto/declarative/qmlecmascript/data/idShortcutInvalidates.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/idShortcutInvalidates.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/jsObject.qml b/tests/auto/declarative/qdeclarativeecmascript/data/jsObject.qml
index 4128c92..4128c92 100644
--- a/tests/auto/declarative/qmlecmascript/data/jsObject.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/jsObject.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/listProperties.qml b/tests/auto/declarative/qdeclarativeecmascript/data/listProperties.qml
index 810f9b6..810f9b6 100644
--- a/tests/auto/declarative/qmlecmascript/data/listProperties.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/listProperties.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/listToVariant.qml b/tests/auto/declarative/qdeclarativeecmascript/data/listToVariant.qml
index 47f4e50..47f4e50 100644
--- a/tests/auto/declarative/qmlecmascript/data/listToVariant.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/listToVariant.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/methods.1.qml b/tests/auto/declarative/qdeclarativeecmascript/data/methods.1.qml
index 0bbee16..0bbee16 100644
--- a/tests/auto/declarative/qmlecmascript/data/methods.1.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/methods.1.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/methods.2.qml b/tests/auto/declarative/qdeclarativeecmascript/data/methods.2.qml
index 9f0c6b1..9f0c6b1 100644
--- a/tests/auto/declarative/qmlecmascript/data/methods.2.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/methods.2.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/methods.3.qml b/tests/auto/declarative/qdeclarativeecmascript/data/methods.3.qml
index 79efc50..79efc50 100644
--- a/tests/auto/declarative/qmlecmascript/data/methods.3.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/methods.3.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/methods.4.qml b/tests/auto/declarative/qdeclarativeecmascript/data/methods.4.qml
index aac711c..aac711c 100644
--- a/tests/auto/declarative/qmlecmascript/data/methods.4.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/methods.4.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/methods.5.qml b/tests/auto/declarative/qdeclarativeecmascript/data/methods.5.qml
index 3d45b15..3d45b15 100644
--- a/tests/auto/declarative/qmlecmascript/data/methods.5.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/methods.5.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/multiEngineObject.qml b/tests/auto/declarative/qdeclarativeecmascript/data/multiEngineObject.qml
index 7da09e4..7da09e4 100644
--- a/tests/auto/declarative/qmlecmascript/data/multiEngineObject.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/multiEngineObject.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/nonExistantAttachedObject.qml b/tests/auto/declarative/qdeclarativeecmascript/data/nonExistantAttachedObject.qml
index f9585db..f9585db 100644
--- a/tests/auto/declarative/qmlecmascript/data/nonExistantAttachedObject.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/nonExistantAttachedObject.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/objectsCompareAsEqual.qml b/tests/auto/declarative/qdeclarativeecmascript/data/objectsCompareAsEqual.qml
index 18e488a..18e488a 100644
--- a/tests/auto/declarative/qmlecmascript/data/objectsCompareAsEqual.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/objectsCompareAsEqual.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/outerBindingOverridesInnerBinding.qml b/tests/auto/declarative/qdeclarativeecmascript/data/outerBindingOverridesInnerBinding.qml
index 0a933e8..0a933e8 100644
--- a/tests/auto/declarative/qmlecmascript/data/outerBindingOverridesInnerBinding.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/outerBindingOverridesInnerBinding.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/scope.2.qml b/tests/auto/declarative/qdeclarativeecmascript/data/scope.2.qml
index 8e5aa0b..8e5aa0b 100644
--- a/tests/auto/declarative/qmlecmascript/data/scope.2.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/scope.2.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/scope.qml b/tests/auto/declarative/qdeclarativeecmascript/data/scope.qml
index cccd3d3..cccd3d3 100644
--- a/tests/auto/declarative/qmlecmascript/data/scope.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/scope.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/scriptAccess.js b/tests/auto/declarative/qdeclarativeecmascript/data/scriptAccess.js
index c00d285..c00d285 100644
--- a/tests/auto/declarative/qmlecmascript/data/scriptAccess.js
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/scriptAccess.js
diff --git a/tests/auto/declarative/qmlecmascript/data/scriptAccess.qml b/tests/auto/declarative/qdeclarativeecmascript/data/scriptAccess.qml
index feb6d16..feb6d16 100644
--- a/tests/auto/declarative/qmlecmascript/data/scriptAccess.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/scriptAccess.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/scriptErrors.js b/tests/auto/declarative/qdeclarativeecmascript/data/scriptErrors.js
index 1d7b357..1d7b357 100644
--- a/tests/auto/declarative/qmlecmascript/data/scriptErrors.js
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/scriptErrors.js
diff --git a/tests/auto/declarative/qmlecmascript/data/scriptErrors.qml b/tests/auto/declarative/qdeclarativeecmascript/data/scriptErrors.qml
index c2edb41..c2edb41 100644
--- a/tests/auto/declarative/qmlecmascript/data/scriptErrors.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/scriptErrors.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/selfDeletingBinding.2.qml b/tests/auto/declarative/qdeclarativeecmascript/data/selfDeletingBinding.2.qml
index 58cf805..58cf805 100644
--- a/tests/auto/declarative/qmlecmascript/data/selfDeletingBinding.2.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/selfDeletingBinding.2.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/selfDeletingBinding.qml b/tests/auto/declarative/qdeclarativeecmascript/data/selfDeletingBinding.qml
index 074851a..074851a 100644
--- a/tests/auto/declarative/qmlecmascript/data/selfDeletingBinding.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/selfDeletingBinding.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/shutdownErrors.qml b/tests/auto/declarative/qdeclarativeecmascript/data/shutdownErrors.qml
index 5a19639..5a19639 100644
--- a/tests/auto/declarative/qmlecmascript/data/shutdownErrors.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/shutdownErrors.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/signalAssignment.1.qml b/tests/auto/declarative/qdeclarativeecmascript/data/signalAssignment.1.qml
index fbd0914..fbd0914 100644
--- a/tests/auto/declarative/qmlecmascript/data/signalAssignment.1.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/signalAssignment.1.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/signalAssignment.2.qml b/tests/auto/declarative/qdeclarativeecmascript/data/signalAssignment.2.qml
index 8addcb9..8addcb9 100644
--- a/tests/auto/declarative/qmlecmascript/data/signalAssignment.2.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/signalAssignment.2.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/signalParameterTypes.qml b/tests/auto/declarative/qdeclarativeecmascript/data/signalParameterTypes.qml
index 6fc8b02..6fc8b02 100644
--- a/tests/auto/declarative/qmlecmascript/data/signalParameterTypes.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/signalParameterTypes.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/signalTriggeredBindings.qml b/tests/auto/declarative/qdeclarativeecmascript/data/signalTriggeredBindings.qml
index 7d419cd..7d419cd 100644
--- a/tests/auto/declarative/qmlecmascript/data/signalTriggeredBindings.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/signalTriggeredBindings.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/transientErrors.qml b/tests/auto/declarative/qdeclarativeecmascript/data/transientErrors.qml
index fa7e01c..fa7e01c 100644
--- a/tests/auto/declarative/qmlecmascript/data/transientErrors.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/transientErrors.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/undefinedResetsProperty.2.qml b/tests/auto/declarative/qdeclarativeecmascript/data/undefinedResetsProperty.2.qml
index e73d38e2..e73d38e2 100644
--- a/tests/auto/declarative/qmlecmascript/data/undefinedResetsProperty.2.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/undefinedResetsProperty.2.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/undefinedResetsProperty.qml b/tests/auto/declarative/qdeclarativeecmascript/data/undefinedResetsProperty.qml
index eceff60..eceff60 100644
--- a/tests/auto/declarative/qmlecmascript/data/undefinedResetsProperty.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/undefinedResetsProperty.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/valueTypeFunctions.qml b/tests/auto/declarative/qdeclarativeecmascript/data/valueTypeFunctions.qml
index 33b4a68..33b4a68 100644
--- a/tests/auto/declarative/qmlecmascript/data/valueTypeFunctions.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/valueTypeFunctions.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/qdeclarativeecmascript.pro b/tests/auto/declarative/qdeclarativeecmascript/qdeclarativeecmascript.pro
new file mode 100644
index 0000000..0e21cb2
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/qdeclarativeecmascript.pro
@@ -0,0 +1,10 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative script
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qdeclarativeecmascript.cpp \
+ testtypes.cpp
+HEADERS += testtypes.h
+
+# QMAKE_CXXFLAGS = -fprofile-arcs -ftest-coverage
+# LIBS += -lgcov
diff --git a/tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp b/tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp
new file mode 100644
index 0000000..6a04704
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "testtypes.h"
+
+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;
+};
+
+void registerTypes()
+{
+ QML_REGISTER_TYPE(Qt.test, 1,0, MyQmlObject,MyQmlObject);
+ QML_REGISTER_TYPE(Qt.test, 1,0, MyDeferredObject,MyDeferredObject);
+ QML_REGISTER_TYPE(Qt.test, 1,0, MyQmlContainer,MyQmlContainer);
+ QML_REGISTER_EXTENDED_TYPE(Qt.test, 1,0, MyBaseExtendedObject,MyBaseExtendedObject,BaseExtensionObject);
+ QML_REGISTER_EXTENDED_TYPE(Qt.test, 1,0, MyExtendedObject,MyExtendedObject,ExtensionObject);
+ QML_REGISTER_TYPE(Qt.test, 1,0, MyTypeObject, MyTypeObject);
+}
+
+#include "testtypes.moc"
diff --git a/tests/auto/declarative/qdeclarativeecmascript/testtypes.h b/tests/auto/declarative/qdeclarativeecmascript/testtypes.h
new file mode 100644
index 0000000..8fbd071
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/testtypes.h
@@ -0,0 +1,598 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef 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 <QtCore/qdatetime.h>
+#include <QtScript/qscriptvalue.h>
+#include <QtDeclarative/qdeclarativescriptstring.h>
+#include <QtDeclarative/qdeclarativecomponent.h>
+
+class MyQmlAttachedObject : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int value READ value CONSTANT)
+public:
+ MyQmlAttachedObject(QObject *parent) : QObject(parent) {}
+
+ int value() const { return 19; }
+};
+
+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(QString stringProperty READ stringProperty WRITE setStringProperty NOTIFY stringChanged)
+ 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)
+
+public:
+ MyQmlObject(): m_methodCalled(false), m_methodIntCalled(false), m_object(0), m_value(0), m_resetProperty(13) {}
+
+ enum MyEnum { EnumValue1 = 0, EnumValue2 = 1 };
+ enum MyEnum2 { EnumValue3 = 2, EnumValue4 = 3 };
+
+ 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();
+ }
+
+ 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; }
+
+signals:
+ void basicSignal();
+ void argumentSignal(int a, QString b, qreal c);
+ void stringChanged();
+ void objectChanged();
+ void anotherBasicSignal();
+ void thirdBasicSignal();
+
+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; }
+
+private:
+ friend class tst_qdeclarativeecmascript;
+ bool m_methodCalled;
+ bool m_methodIntCalled;
+
+ QObject *m_object;
+ QString m_string;
+ QList<QObject *> m_objectQList;
+ int m_value;
+ int m_resetProperty;
+};
+
+QML_DECLARE_TYPEINFO(MyQmlObject, QML_HAS_ATTACHED_PROPERTIES)
+QML_DECLARE_TYPE(MyQmlObject);
+
+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;
+};
+
+QML_DECLARE_TYPE(MyQmlContainer);
+
+class MyExpression : public QDeclarativeExpression
+{
+ Q_OBJECT
+public:
+ MyExpression(QDeclarativeContext *ctxt, const QString &expr)
+ : QDeclarativeExpression(ctxt, expr, 0), 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);
+public:
+ int horseLegs() const { return 4; }
+ int antLegs() const { return 6; }
+};
+
+class MyDefaultObject2 : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int antLegs READ antLegs CONSTANT);
+ Q_PROPERTY(int emuLegs READ emuLegs CONSTANT);
+public:
+ int antLegs() const { return 5; } // Had an accident
+ 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;
+};
+QML_DECLARE_TYPE(MyDeferredObject);
+
+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;
+};
+QML_DECLARE_TYPE(MyBaseExtendedObject);
+
+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;
+};
+QML_DECLARE_TYPE(MyExtendedObject);
+
+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)
+QML_DECLARE_TYPE(MyTypeObject);
+
+Q_DECLARE_METATYPE(QScriptValue);
+class MyInvokableObject : public QObject
+{
+ Q_OBJECT
+public:
+ 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.7; }
+ 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 QScriptValue method_NoArgs_QScriptValue() { invoke(6); return QScriptValue("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(QScriptValue a) { invoke(14); m_actuals << qVariantFromValue(a); }
+ Q_INVOKABLE void method_intQScriptValue(int a, QScriptValue 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; }
+
+private:
+ void invoke(int idx) { if (m_invoked != -1) m_invokedError = true; m_invoked = idx;}
+ int m_invoked;
+ bool m_invokedError;
+ QVariantList m_actuals;
+};
+
+void registerTypes();
+
+#endif // TESTTYPES_H
+
diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
new file mode 100644
index 0000000..60c380c
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
@@ -0,0 +1,1662 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#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/qdeclarativeglobalscriptclass_p.h>
+#include "testtypes.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
+*/
+inline QUrl TEST_FILE(const QString &filename)
+{
+ QFileInfo fileInfo(__FILE__);
+ return QUrl::fromLocalFile(fileInfo.absoluteDir().filePath("data/" + filename));
+}
+
+inline QUrl TEST_FILE(const char *filename)
+{
+ return TEST_FILE(QLatin1String(filename));
+}
+
+class tst_qdeclarativeecmascript : public QObject
+{
+ 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 extensionObjects();
+ void attachedProperties();
+ void enums();
+ void valueTypeFunctions();
+ void constantsOverrideBindings();
+ void outerBindingOverridesInnerBinding();
+ void aliasPropertyAndBinding();
+ void nonExistantAttachedObject();
+ void scope();
+ void signalParameterTypes();
+ void objectsCompareAsEqual();
+ void scriptAccess();
+ void dynamicCreation_data();
+ void dynamicCreation();
+ void dynamicDestruction();
+ void objectToString();
+ void selfDeletingBinding();
+ void extendedObjectPropertyLookup();
+ void scriptErrors();
+ void signalTriggeredBindings();
+ void listProperties();
+ void exceptionClearsOnReeval();
+ void exceptionSlotProducesWarning();
+ void exceptionBindingProducesWarning();
+ void transientErrors();
+ void shutdownErrors();
+ void externalScript();
+ void compositePropertyType();
+ void jsObject();
+ void undefinedResetsProperty();
+ void listToVariant();
+ void multiEngineObject();
+ void deletedObject();
+
+ void bug1();
+
+ void callQtInvokables();
+private:
+ QDeclarativeEngine engine;
+};
+
+void tst_qdeclarativeecmascript::initTestCase() { registerTypes(); }
+
+void tst_qdeclarativeecmascript::assignBasicTypes()
+{
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("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.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->urlProperty(), component.url().resolved(QUrl("main.qml")));
+ delete object;
+ }
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("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.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->urlProperty(), component.url().resolved(QUrl("main.qml")));
+ delete object;
+ }
+}
+
+void tst_qdeclarativeecmascript::idShortcutInvalidates()
+{
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("idShortcutInvalidates.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+ QVERIFY(object->objectProperty() != 0);
+ delete object->objectProperty();
+ QVERIFY(object->objectProperty() == 0);
+ }
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("idShortcutInvalidates.1.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+ QVERIFY(object->objectProperty() != 0);
+ delete object->objectProperty();
+ QVERIFY(object->objectProperty() == 0);
+ }
+}
+
+void tst_qdeclarativeecmascript::boolPropertiesEvaluateAsBool()
+{
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("boolPropertiesEvaluateAsBool.1.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->stringProperty(), QLatin1String("pass"));
+ }
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("boolPropertiesEvaluateAsBool.2.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->stringProperty(), QLatin1String("pass"));
+ }
+}
+
+void tst_qdeclarativeecmascript::signalAssignment()
+{
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("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"));
+ }
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("signalAssignment.2.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->string(), QString());
+ emit object->argumentSignal(19, "Hello world!", 10.3);
+ QCOMPARE(object->string(), QString("pass 19 Hello world! 10.3"));
+ }
+}
+
+void tst_qdeclarativeecmascript::methods()
+{
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("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);
+ }
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("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);
+ }
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("methods.3.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QCOMPARE(object->property("test").toInt(), 19);
+ }
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("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);
+ }
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("methods.5.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QCOMPARE(object->property("test").toInt(), 9);
+ }
+}
+
+void tst_qdeclarativeecmascript::bindingLoop()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("bindingLoop.qml"));
+ QString warning = "QML MyQmlObject (" + component.url().toString() + ":9:9) Binding loop detected for property \"stringProperty\"";
+ QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData());
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+}
+
+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;
+ MyDefaultObject2 default2;
+ MyDefaultObject3 default3;
+ object1.setStringProperty("Object1");
+ object2.setStringProperty("Object2");
+ object3.setStringProperty("Object3");
+
+ QDeclarativeContext context(engine.rootContext());
+ QDeclarativeContext nestedContext(&context);
+
+ context.addDefaultObject(&default1);
+ context.addDefaultObject(&default2);
+ context.setContextProperty("a", QVariant(1944));
+ context.setContextProperty("b", QVariant("Milk"));
+ context.setContextProperty("object", &object1);
+ context.setContextProperty("objectOverride", &object2);
+ nestedContext.addDefaultObject(&default3);
+ nestedContext.setContextProperty("b", QVariant("Cow"));
+ nestedContext.setContextProperty("objectOverride", &object3);
+ nestedContext.setContextProperty("millipedeLegs", QVariant(100));
+
+ MyExpression expr(nest?&nestedContext:&context, expression);
+ QCOMPARE(expr.value(), 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.value();
+ 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.value(), QVariant(2));
+
+ context.setContextProperty("testProp", QVariant(2));
+ QCOMPARE(expr.changed, true);
+ QCOMPARE(expr.value(), QVariant(3));
+ }
+
+ {
+ MyExpression expr(&context, "testProp + testProp + testProp");
+ QCOMPARE(expr.changed, false);
+ QCOMPARE(expr.value(), QVariant(6));
+
+ context.setContextProperty("testProp", QVariant(4));
+ QCOMPARE(expr.changed, true);
+ QCOMPARE(expr.value(), QVariant(12));
+ }
+
+ {
+ MyExpression expr(&context, "testObj.stringProperty");
+ QCOMPARE(expr.changed, false);
+ QCOMPARE(expr.value(), QVariant("Hello"));
+
+ context.setContextProperty("testObj", &object2);
+ QCOMPARE(expr.changed, true);
+ QCOMPARE(expr.value(), QVariant("World"));
+ }
+
+ {
+ MyExpression expr(&context, "testObj.stringProperty /**/");
+ QCOMPARE(expr.changed, false);
+ QCOMPARE(expr.value(), QVariant("World"));
+
+ context.setContextProperty("testObj", &object1);
+ QCOMPARE(expr.changed, true);
+ QCOMPARE(expr.value(), QVariant("Hello"));
+ }
+
+ {
+ MyExpression expr(&context, "testObj2");
+ QCOMPARE(expr.changed, false);
+ QCOMPARE(expr.value(), QVariant::fromValue((QObject *)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.value(), QVariant("Hello"));
+
+ object1.setStringProperty(QLatin1String("World"));
+ QCOMPARE(expr.changed, true);
+ QCOMPARE(expr.value(), QVariant("World"));
+ }
+
+ {
+ MyExpression expr(&context, "testObj.objectProperty.stringProperty");
+ QCOMPARE(expr.changed, false);
+ QCOMPARE(expr.value(), QVariant());
+
+ object1.setObjectProperty(&object2);
+ QCOMPARE(expr.changed, true);
+ expr.changed = false;
+ QCOMPARE(expr.value(), QVariant("Dog"));
+
+ object1.setObjectProperty(&object3);
+ QCOMPARE(expr.changed, true);
+ expr.changed = false;
+ QCOMPARE(expr.value(), QVariant("Cat"));
+
+ object1.setObjectProperty(0);
+ QCOMPARE(expr.changed, true);
+ expr.changed = false;
+ QCOMPARE(expr.value(), QVariant());
+
+ object1.setObjectProperty(&object3);
+ QCOMPARE(expr.changed, true);
+ expr.changed = false;
+ QCOMPARE(expr.value(), QVariant("Cat"));
+
+ object3.setStringProperty("Donkey");
+ QCOMPARE(expr.changed, true);
+ expr.changed = false;
+ QCOMPARE(expr.value(), QVariant("Donkey"));
+ }
+}
+
+void tst_qdeclarativeecmascript::deferredProperties()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("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);
+}
+
+void tst_qdeclarativeecmascript::extensionObjects()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("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);
+}
+
+void tst_qdeclarativeecmascript::attachedProperties()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("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);
+
+ // ### Need to test attached property assignment
+}
+
+void tst_qdeclarativeecmascript::enums()
+{
+ // Existant enums
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("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);
+ }
+ // Non-existent enums
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("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);
+ }
+}
+
+void tst_qdeclarativeecmascript::valueTypeFunctions()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("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));
+}
+
+/*
+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, TEST_FILE("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);
+ }
+
+ // During construction
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("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);
+ }
+
+#if 0
+ // From C++
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("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);
+ }
+#endif
+}
+
+/*
+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,
+ TEST_FILE("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);
+}
+
+/*
+Access a non-existent attached object.
+
+Tests for a regression where this used to crash.
+*/
+void tst_qdeclarativeecmascript::nonExistantAttachedObject()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("nonExistantAttachedObject.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);
+}
+
+void tst_qdeclarativeecmascript::scope()
+{
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("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);
+ }
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("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(), 11);
+ QCOMPARE(object->property("test4").toInt(), 11);
+ QCOMPARE(object->property("test5").toInt(), 24);
+ QCOMPARE(object->property("test6").toInt(), 24);
+ }
+}
+
+/*
+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, TEST_FILE("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)));
+}
+
+/*
+Test that two JS objects for the same QObject compare as equal.
+*/
+void tst_qdeclarativeecmascript::objectsCompareAsEqual()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("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);
+}
+
+/*
+Confirm bindings and alias properties can coexist.
+
+Tests for a regression where the binding would not reevaluate.
+*/
+void tst_qdeclarativeecmascript::aliasPropertyAndBinding()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("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);
+}
+
+/*
+Tests that only methods of Script {} blocks are exposed.
+*/
+void tst_qdeclarativeecmascript::scriptAccess()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("scriptAccess.qml"));
+
+ QString warning = component.url().toString() + ":16: Unable to assign [undefined] to int";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test1").toInt(), 10);
+ QCOMPARE(object->property("test2").toInt(), 19);
+ QCOMPARE(object->property("test3").toInt(), 0);
+}
+
+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, TEST_FILE("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);
+}
+
+/*
+ Tests the destroy function
+*/
+void tst_qdeclarativeecmascript::dynamicDestruction()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("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::instance()->processEvents(QEventLoop::DeferredDeletion);
+ QVERIFY(createdQmlObject);
+ for (int ii = 0; createdQmlObject && ii < 50; ++ii) { // After 5 seconds we should give up
+ if (createdQmlObject) {
+ QTest::qWait(100);
+ QCoreApplication::instance()->processEvents(QEventLoop::DeferredDeletion);
+ }
+ }
+ QVERIFY(!createdQmlObject);
+
+ QMetaObject::invokeMethod(object, "killMe");
+ QVERIFY(object);
+ QTest::qWait(0);
+ QCoreApplication::instance()->processEvents(QEventLoop::DeferredDeletion);
+ QVERIFY(!object);
+}
+
+/*
+ tests that id.toString() works
+*/
+void tst_qdeclarativeecmascript::objectToString()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("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\")"));
+}
+
+/*
+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, TEST_FILE("selfDeletingBinding.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ object->setProperty("triggerDelete", true);
+ }
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("selfDeletingBinding.2.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ object->setProperty("triggerDelete", true);
+ }
+}
+
+/*
+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, TEST_FILE("extendedObjectPropertyLookup.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+}
+
+/*
+Test file/lineNumbers for binding/Script errors.
+*/
+void tst_qdeclarativeecmascript::scriptErrors()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("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 + ":7: TypeError: Result of expression 'a' [undefined] is not an object.";
+ QString warning3 = url + ":5: Error: Invalid write to global property \"a\"";
+ QString warning4 = url + ":12: TypeError: Result of expression 'a' [undefined] is not an object.";
+ QString warning5 = url + ":10: TypeError: Result of expression 'a' [undefined] is not an object.";
+ QString warning6 = url + ":9: Unable to assign [undefined] to int";
+ QString warning7 = url + ":14: Error: Cannot assign to read-only property \"trueProperty\"";
+ QString warning8 = url + ":15: 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();
+}
+
+/*
+Test bindings still work when the reeval is triggered from within
+a signal script.
+*/
+void tst_qdeclarativeecmascript::signalTriggeredBindings()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("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);
+
+ QCOMPARE(object->property("base").toReal(), 400.);
+ QCOMPARE(object->property("test1").toReal(), 400.);
+ QCOMPARE(object->property("test2").toReal(), 400.);
+}
+
+/*
+Test that list properties can be iterated from ECMAScript
+*/
+void tst_qdeclarativeecmascript::listProperties()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("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);
+}
+
+void tst_qdeclarativeecmascript::exceptionClearsOnReeval()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("exceptionClearsOnReeval.qml"));
+ QString url = component.url().toString();
+
+ QString warning = url + ":4: TypeError: Result of expression 'objectProperty.objectProperty' [undefined] is not an object.";
+
+ 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);
+}
+
+void tst_qdeclarativeecmascript::exceptionSlotProducesWarning()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("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);
+}
+
+void tst_qdeclarativeecmascript::exceptionBindingProducesWarning()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("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);
+}
+
+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, TEST_FILE("transientErrors.qml"));
+
+ transientErrorsMsgCount = 0;
+ QtMsgHandler old = qInstallMsgHandler(transientErrorsMsgHandler);
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ qInstallMsgHandler(old);
+
+ QCOMPARE(transientErrorsMsgCount, 0);
+}
+
+// Check that errors during shutdown are minimized
+void tst_qdeclarativeecmascript::shutdownErrors()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("shutdownErrors.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ transientErrorsMsgCount = 0;
+ QtMsgHandler old = qInstallMsgHandler(transientErrorsMsgHandler);
+
+ delete object;
+
+ qInstallMsgHandler(old);
+ QCOMPARE(transientErrorsMsgCount, 0);
+}
+
+// Check that Script::source property works as expected
+void tst_qdeclarativeecmascript::externalScript()
+{
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("externalScript.1.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toInt(), 92);
+
+ delete object;
+ }
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("externalScript.2.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toInt(), 92);
+
+ delete object;
+ }
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("externalScript.3.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toInt(), 92);
+ QCOMPARE(object->property("test2").toInt(), 92);
+ QCOMPARE(object->property("test3").toBool(), false);
+
+ delete object;
+ }
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("externalScript.4.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toInt(), 92);
+ QCOMPARE(object->property("test2").toBool(), true);
+
+ delete object;
+ }
+}
+
+void tst_qdeclarativeecmascript::compositePropertyType()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("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, TEST_FILE("jsObject.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toInt(), 92);
+
+ delete object;
+}
+
+void tst_qdeclarativeecmascript::undefinedResetsProperty()
+{
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("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, TEST_FILE("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;
+ }
+}
+
+// QTBUG-6781
+void tst_qdeclarativeecmascript::bug1()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("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::callQtInvokables()
+{
+ MyInvokableObject o;
+
+ QDeclarativeEngine qmlengine;
+ QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(&qmlengine);
+ QScriptEngine *engine = &ep->scriptEngine;
+ ep->globalClass->explicitSetProperty("object", ep->objectClass->newQObject(&o));
+
+ // Non-existent methods
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_nonexistent()").isError(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), -1);
+ QCOMPARE(o.actuals().count(), 0);
+
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_nonexistent(10, 11)").isError(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), -1);
+ QCOMPARE(o.actuals().count(), 0);
+
+ // Insufficient arguments
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_int()").isError(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), -1);
+ QCOMPARE(o.actuals().count(), 0);
+
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_intint(10)").isError(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), -1);
+ QCOMPARE(o.actuals().count(), 0);
+
+ // Excessive arguments
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_int(10, 11)").isUndefined(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 8);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(10));
+
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_intint(10, 11, 12)").isUndefined(), true);
+ 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();
+ QCOMPARE(engine->evaluate("object.method_NoArgs()").isUndefined(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 0);
+ QCOMPARE(o.actuals().count(), 0);
+
+ o.reset();
+ QVERIFY(engine->evaluate("object.method_NoArgs_int()").strictlyEquals(QScriptValue(engine, 6)));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 1);
+ QCOMPARE(o.actuals().count(), 0);
+
+ o.reset();
+ QVERIFY(engine->evaluate("object.method_NoArgs_real()").strictlyEquals(QScriptValue(engine, 19.7)));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 2);
+ QCOMPARE(o.actuals().count(), 0);
+
+ o.reset();
+ {
+ QScriptValue ret = engine->evaluate("object.method_NoArgs_QPointF()");
+ QVERIFY(ret.isVariant());
+ QCOMPARE(ret.toVariant(), QVariant(QPointF(123, 4.5)));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 3);
+ QCOMPARE(o.actuals().count(), 0);
+ }
+
+ o.reset();
+ {
+ QScriptValue ret = engine->evaluate("object.method_NoArgs_QObject()");
+ QVERIFY(ret.isQObject());
+ QCOMPARE(ret.toQObject(), (QObject *)&o);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 4);
+ QCOMPARE(o.actuals().count(), 0);
+ }
+
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_NoArgs_unknown()").isUndefined(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 5);
+ QCOMPARE(o.actuals().count(), 0);
+
+ o.reset();
+ {
+ QScriptValue ret = engine->evaluate("object.method_NoArgs_QScriptValue()");
+ QVERIFY(ret.isString());
+ QCOMPARE(ret.toString(), QString("Hello world"));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 6);
+ QCOMPARE(o.actuals().count(), 0);
+ }
+
+ o.reset();
+ QVERIFY(engine->evaluate("object.method_NoArgs_QVariant()").strictlyEquals(QScriptValue(engine, "QML rocks")));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 7);
+ QCOMPARE(o.actuals().count(), 0);
+
+ // Test arg types
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_int(94)").isUndefined(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 8);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(94));
+
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_int(\"94\")").isUndefined(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 8);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(94));
+
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_int(\"not a number\")").isUndefined(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 8);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(0));
+
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_int(null)").isUndefined(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 8);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(0));
+
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_int(undefined)").isUndefined(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 8);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(0));
+
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_int(object)").isUndefined(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 8);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(0));
+
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_intint(122, 9)").isUndefined(), true);
+ 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();
+ QCOMPARE(engine->evaluate("object.method_real(94.3)").isUndefined(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 10);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(94.3));
+
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_real(\"94.3\")").isUndefined(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 10);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(94.3));
+
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_real(\"not a number\")").isUndefined(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 10);
+ QCOMPARE(o.actuals().count(), 1);
+ QVERIFY(qIsNaN(o.actuals().at(0).toDouble()));
+
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_real(null)").isUndefined(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 10);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(0));
+
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_real(undefined)").isUndefined(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 10);
+ QCOMPARE(o.actuals().count(), 1);
+ QVERIFY(qIsNaN(o.actuals().at(0).toDouble()));
+
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_real(object)").isUndefined(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 10);
+ QCOMPARE(o.actuals().count(), 1);
+ QVERIFY(qIsNaN(o.actuals().at(0).toDouble()));
+
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_QString(\"Hello world\")").isUndefined(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 11);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant("Hello world"));
+
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_QString(19)").isUndefined(), true);
+ 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((intptr_t)&o, 16) + ")";
+ QCOMPARE(engine->evaluate("object.method_QString(object)").isUndefined(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 11);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(expected));
+ }
+
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_QString(null)").isUndefined(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 11);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(QString()));
+
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_QString(undefined)").isUndefined(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 11);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(QString()));
+
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_QPointF(0)").isUndefined(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 12);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(QPointF()));
+
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_QPointF(null)").isUndefined(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 12);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(QPointF()));
+
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_QPointF(undefined)").isUndefined(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 12);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(QPointF()));
+
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_QPointF(object)").isUndefined(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 12);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(QPointF()));
+
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_QPointF(object.method_get_QPointF())").isUndefined(), true);
+ 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();
+ QCOMPARE(engine->evaluate("object.method_QPointF(object.method_get_QPoint())").isUndefined(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 12);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(QPointF(9, 12)));
+
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_QObject(0)").isUndefined(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 13);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), qVariantFromValue((QObject *)0));
+
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_QObject(\"Hello world\")").isUndefined(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 13);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), qVariantFromValue((QObject *)0));
+
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_QObject(null)").isUndefined(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 13);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), qVariantFromValue((QObject *)0));
+
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_QObject(undefined)").isUndefined(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 13);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), qVariantFromValue((QObject *)0));
+
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_QObject(object)").isUndefined(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 13);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), qVariantFromValue((QObject *)&o));
+
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_QScriptValue(null)").isUndefined(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 14);
+ QCOMPARE(o.actuals().count(), 1);
+ QVERIFY(qvariant_cast<QScriptValue>(o.actuals().at(0)).isNull());
+
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_QScriptValue(undefined)").isUndefined(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 14);
+ QCOMPARE(o.actuals().count(), 1);
+ QVERIFY(qvariant_cast<QScriptValue>(o.actuals().at(0)).isUndefined());
+
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_QScriptValue(19)").isUndefined(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 14);
+ QCOMPARE(o.actuals().count(), 1);
+ QVERIFY(qvariant_cast<QScriptValue>(o.actuals().at(0)).strictlyEquals(QScriptValue(engine, 19)));
+
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_QScriptValue([19, 20])").isUndefined(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 14);
+ QCOMPARE(o.actuals().count(), 1);
+ QVERIFY(qvariant_cast<QScriptValue>(o.actuals().at(0)).isArray());
+
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_intQScriptValue(4, null)").isUndefined(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 15);
+ QCOMPARE(o.actuals().count(), 2);
+ QCOMPARE(o.actuals().at(0), QVariant(4));
+ QVERIFY(qvariant_cast<QScriptValue>(o.actuals().at(1)).isNull());
+
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_intQScriptValue(8, undefined)").isUndefined(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 15);
+ QCOMPARE(o.actuals().count(), 2);
+ QCOMPARE(o.actuals().at(0), QVariant(8));
+ QVERIFY(qvariant_cast<QScriptValue>(o.actuals().at(1)).isUndefined());
+
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_intQScriptValue(3, 19)").isUndefined(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 15);
+ QCOMPARE(o.actuals().count(), 2);
+ QCOMPARE(o.actuals().at(0), QVariant(3));
+ QVERIFY(qvariant_cast<QScriptValue>(o.actuals().at(1)).strictlyEquals(QScriptValue(engine, 19)));
+
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_intQScriptValue(44, [19, 20])").isUndefined(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 15);
+ QCOMPARE(o.actuals().count(), 2);
+ QCOMPARE(o.actuals().at(0), QVariant(44));
+ QVERIFY(qvariant_cast<QScriptValue>(o.actuals().at(1)).isArray());
+
+ // Test overloads - QML will always invoke the *last* method
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_overload()").isError(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), -1);
+ QCOMPARE(o.actuals().count(), 0);
+
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_overload(10)").isError(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), -1);
+ QCOMPARE(o.actuals().count(), 0);
+
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_overload(10, 11)").isUndefined(), true);
+ 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));
+}
+
+// QTBUG-5675
+void tst_qdeclarativeecmascript::listToVariant()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("listToVariant.qml"));
+
+ MyQmlContainer container;
+
+ QDeclarativeContext context(engine.rootContext());
+ context.addDefaultObject(&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-7957
+void tst_qdeclarativeecmascript::multiEngineObject()
+{
+ MyQmlObject obj;
+ obj.setStringProperty("Howdy planet");
+
+ QDeclarativeEngine e1;
+ e1.rootContext()->setContextProperty("thing", &obj);
+ QDeclarativeComponent c1(&e1, TEST_FILE("multiEngineObject.qml"));
+
+ QDeclarativeEngine e2;
+ e2.rootContext()->setContextProperty("thing", &obj);
+ QDeclarativeComponent c2(&e2, TEST_FILE("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, TEST_FILE("deletedObject.qml"));
+
+ QObject *object = component.create();
+
+ QCOMPARE(object->property("test1").toBool(), true);
+ QCOMPARE(object->property("test2").toBool(), true);
+ QCOMPARE(object->property("test3").toBool(), true);
+ QEXPECT_FAIL("", "QTBUG-8077", Continue);
+ QCOMPARE(object->property("test4").toBool(), 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
new file mode 100644
index 0000000..5b6530d
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeengine/qdeclarativeengine.pro
@@ -0,0 +1,8 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative network
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qdeclarativeengine.cpp
+
+# Define SRCDIR equal to test's source directory
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qdeclarativeengine/tst_qdeclarativeengine.cpp b/tests/auto/declarative/qdeclarativeengine/tst_qdeclarativeengine.cpp
new file mode 100644
index 0000000..5dc5f19
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeengine/tst_qdeclarativeengine.cpp
@@ -0,0 +1,240 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+#include <QDeclarativeEngine>
+#include <QDeclarativeContext>
+#include <QNetworkAccessManager>
+#include <QPointer>
+#include <QDir>
+#include <QDesktopServices>
+#include <QDebug>
+#include <QDeclarativeComponent>
+#include <QDeclarativeNetworkAccessManagerFactory>
+
+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 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->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(QDesktopServices::storageLocation(QDesktopServices::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 Qt 4.6\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 Qt 4.6\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;
+ }
+}
+
+QTEST_MAIN(tst_qdeclarativeengine)
+
+#include "tst_qdeclarativeengine.moc"
diff --git a/tests/auto/declarative/qdeclarativeerror/qdeclarativeerror.pro b/tests/auto/declarative/qdeclarativeerror/qdeclarativeerror.pro
new file mode 100644
index 0000000..6591406
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeerror/qdeclarativeerror.pro
@@ -0,0 +1,6 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative
+SOURCES += tst_qdeclarativeerror.cpp
+macx:CONFIG -= app_bundle
+
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmlerror/test.txt b/tests/auto/declarative/qdeclarativeerror/test.txt
index cdafd9e..cdafd9e 100644
--- a/tests/auto/declarative/qmlerror/test.txt
+++ b/tests/auto/declarative/qdeclarativeerror/test.txt
diff --git a/tests/auto/declarative/qdeclarativeerror/tst_qdeclarativeerror.cpp b/tests/auto/declarative/qdeclarativeerror/tst_qdeclarativeerror.cpp
new file mode 100644
index 0000000..ba1ebae
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeerror/tst_qdeclarativeerror.cpp
@@ -0,0 +1,242 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+#include <QDeclarativeError>
+#include <QDebug>
+
+class tst_qdeclarativeerror : public QObject
+{
+ 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(QUrl::fromLocalFile(QString(SRCDIR) + "/").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(QUrl::fromLocalFile(QString(SRCDIR) + "/").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/qmlgraphicsflickable/data/flickable01.qml b/tests/auto/declarative/qdeclarativeflickable/data/flickable01.qml
index 8a1843c..8a1843c 100644
--- a/tests/auto/declarative/qmlgraphicsflickable/data/flickable01.qml
+++ b/tests/auto/declarative/qdeclarativeflickable/data/flickable01.qml
diff --git a/tests/auto/declarative/qdeclarativeflickable/data/flickable02.qml b/tests/auto/declarative/qdeclarativeflickable/data/flickable02.qml
new file mode 100644
index 0000000..4b82d5c
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeflickable/data/flickable02.qml
@@ -0,0 +1,14 @@
+import Qt 4.6
+
+Flickable {
+ width: 100; height: 100
+ contentWidth: row.width; contentHeight: row.height
+
+ Row {
+ id: row
+ Repeater {
+ model: 4
+ Rectangle { width: 200; height: 300; color: "blue" }
+ }
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativeflickable/data/flickable03.qml b/tests/auto/declarative/qdeclarativeflickable/data/flickable03.qml
new file mode 100644
index 0000000..49eed5a
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeflickable/data/flickable03.qml
@@ -0,0 +1,14 @@
+import Qt 4.6
+
+Flickable {
+ width: 100; height: 100
+ contentWidth: column.width; contentHeight: column.height
+
+ Column {
+ id: column
+ Repeater {
+ model: 4
+ Rectangle { width: 200; height: 300; color: "blue" }
+ }
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativeflickable/data/flickable04.qml b/tests/auto/declarative/qdeclarativeflickable/data/flickable04.qml
new file mode 100644
index 0000000..40c4606
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeflickable/data/flickable04.qml
@@ -0,0 +1,16 @@
+import Qt 4.6
+
+Flickable {
+ width: 100; height: 100
+ contentWidth: column.width; contentHeight: column.height
+ pressDelay: 200; overShoot: false; interactive: false
+ maximumFlickVelocity: 2000
+
+ Column {
+ id: column
+ Repeater {
+ model: 4
+ Rectangle { width: 200; height: 300; color: "blue" }
+ }
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativeflickable/qdeclarativeflickable.pro b/tests/auto/declarative/qdeclarativeflickable/qdeclarativeflickable.pro
new file mode 100644
index 0000000..4b71381
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeflickable/qdeclarativeflickable.pro
@@ -0,0 +1,8 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative gui
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qdeclarativeflickable.cpp
+
+# Define SRCDIR equal to test's source directory
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp b/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp
new file mode 100644
index 0000000..cb87977
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp
@@ -0,0 +1,223 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QtTest/QSignalSpy>
+#include <QtDeclarative/qdeclarativeengine.h>
+#include <QtDeclarative/qdeclarativecomponent.h>
+#include <private/qdeclarativeflickable_p.h>
+#include <private/qdeclarativevaluetype_p.h>
+#include <math.h>
+
+class tst_qdeclarativeflickable : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qdeclarativeflickable();
+
+private slots:
+ void create();
+ void horizontalViewportSize();
+ void verticalViewportSize();
+ void properties();
+ void overShoot();
+ void maximumFlickVelocity();
+ void flickDeceleration();
+ void pressDelay();
+
+private:
+ QDeclarativeEngine engine;
+};
+
+tst_qdeclarativeflickable::tst_qdeclarativeflickable()
+{
+}
+
+void tst_qdeclarativeflickable::create()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/flickable01.qml"));
+ QDeclarativeFlickable *obj = qobject_cast<QDeclarativeFlickable*>(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->overShoot(), true);
+ QCOMPARE(obj->pressDelay(), 0);
+ QCOMPARE(obj->maximumFlickVelocity(), 2000.);
+
+ delete obj;
+}
+
+void tst_qdeclarativeflickable::horizontalViewportSize()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/flickable02.qml"));
+ QDeclarativeFlickable *obj = qobject_cast<QDeclarativeFlickable*>(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_qdeclarativeflickable::verticalViewportSize()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/flickable03.qml"));
+ QDeclarativeFlickable *obj = qobject_cast<QDeclarativeFlickable*>(c.create());
+
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->contentWidth(), 200.);
+ QCOMPARE(obj->contentHeight(), 1200.);
+ QCOMPARE(obj->isAtXBeginning(), true);
+ QCOMPARE(obj->isAtXEnd(), false);
+ QCOMPARE(obj->isAtYBeginning(), true);
+ QCOMPARE(obj->isAtYEnd(), false);
+
+ delete obj;
+}
+
+void tst_qdeclarativeflickable::properties()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/flickable04.qml"));
+ QDeclarativeFlickable *obj = qobject_cast<QDeclarativeFlickable*>(c.create());
+
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->isInteractive(), false);
+ QCOMPARE(obj->overShoot(), false);
+ QCOMPARE(obj->pressDelay(), 200);
+ QCOMPARE(obj->maximumFlickVelocity(), 2000.);
+
+ delete obj;
+}
+
+void tst_qdeclarativeflickable::overShoot()
+{
+ QDeclarativeComponent component(&engine);
+ component.setData("import Qt 4.6; Flickable { overShoot: false; }", QUrl::fromLocalFile(""));
+ QDeclarativeFlickable *flickable = qobject_cast<QDeclarativeFlickable*>(component.create());
+ QSignalSpy spy(flickable, SIGNAL(overShootChanged()));
+
+ QVERIFY(flickable);
+ QVERIFY(!flickable->overShoot());
+
+ flickable->setOverShoot(true);
+ QVERIFY(flickable->overShoot());
+ QCOMPARE(spy.count(),1);
+ flickable->setOverShoot(true);
+ QCOMPARE(spy.count(),1);
+
+ flickable->setOverShoot(false);
+ QVERIFY(!flickable->overShoot());
+ QCOMPARE(spy.count(),2);
+ flickable->setOverShoot(false);
+ QCOMPARE(spy.count(),2);
+}
+
+void tst_qdeclarativeflickable::maximumFlickVelocity()
+{
+ QDeclarativeComponent component(&engine);
+ component.setData("import Qt 4.6; Flickable { maximumFlickVelocity: 1.0; }", QUrl::fromLocalFile(""));
+ QDeclarativeFlickable *flickable = qobject_cast<QDeclarativeFlickable*>(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_qdeclarativeflickable::flickDeceleration()
+{
+ QDeclarativeComponent component(&engine);
+ component.setData("import Qt 4.6; Flickable { flickDeceleration: 1.0; }", QUrl::fromLocalFile(""));
+ QDeclarativeFlickable *flickable = qobject_cast<QDeclarativeFlickable*>(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_qdeclarativeflickable::pressDelay()
+{
+ QDeclarativeComponent component(&engine);
+ component.setData("import Qt 4.6; Flickable { pressDelay: 100; }", QUrl::fromLocalFile(""));
+ QDeclarativeFlickable *flickable = qobject_cast<QDeclarativeFlickable*>(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);
+}
+
+QTEST_MAIN(tst_qdeclarativeflickable)
+
+#include "tst_qdeclarativeflickable.moc"
diff --git a/tests/auto/declarative/qmlgraphicsflipable/data/test-flipable.qml b/tests/auto/declarative/qdeclarativeflipable/data/test-flipable.qml
index 21d356d..21d356d 100644
--- a/tests/auto/declarative/qmlgraphicsflipable/data/test-flipable.qml
+++ b/tests/auto/declarative/qdeclarativeflipable/data/test-flipable.qml
diff --git a/tests/auto/declarative/qdeclarativeflipable/qdeclarativeflipable.pro b/tests/auto/declarative/qdeclarativeflipable/qdeclarativeflipable.pro
new file mode 100644
index 0000000..e29d324
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeflipable/qdeclarativeflipable.pro
@@ -0,0 +1,8 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative gui
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qdeclarativeflipable.cpp
+
+# Define SRCDIR equal to test's source directory
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qdeclarativeflipable/tst_qdeclarativeflipable.cpp b/tests/auto/declarative/qdeclarativeflipable/tst_qdeclarativeflipable.cpp
new file mode 100644
index 0000000..ed37c43
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeflipable/tst_qdeclarativeflipable.cpp
@@ -0,0 +1,113 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QtDeclarative/qdeclarativeengine.h>
+#include <QtDeclarative/qdeclarativecomponent.h>
+#include <private/qdeclarativeflipable_p.h>
+#include <private/qdeclarativevaluetype_p.h>
+#include <QFontMetrics>
+#include <private/qdeclarativerectangle_p.h>
+#include <math.h>
+
+class tst_qdeclarativeflipable : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qdeclarativeflipable();
+
+private slots:
+ void create();
+ void checkFrontAndBack();
+ void setFrontAndBack();
+
+private:
+ QDeclarativeEngine engine;
+};
+
+tst_qdeclarativeflipable::tst_qdeclarativeflipable()
+{
+}
+
+void tst_qdeclarativeflipable::create()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/test-flipable.qml"));
+ QDeclarativeFlipable *obj = qobject_cast<QDeclarativeFlipable*>(c.create());
+
+ QVERIFY(obj != 0);
+ delete obj;
+}
+
+void tst_qdeclarativeflipable::checkFrontAndBack()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/test-flipable.qml"));
+ QDeclarativeFlipable *obj = qobject_cast<QDeclarativeFlipable*>(c.create());
+
+ QVERIFY(obj != 0);
+ QVERIFY(obj->front() != 0);
+ QVERIFY(obj->back() != 0);
+ delete obj;
+}
+
+void tst_qdeclarativeflipable::setFrontAndBack()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/test-flipable.qml"));
+ QDeclarativeFlipable *obj = qobject_cast<QDeclarativeFlipable*>(c.create());
+
+ QVERIFY(obj != 0);
+ QVERIFY(obj->front() != 0);
+ QVERIFY(obj->back() != 0);
+
+ QString message = "QML Flipable (" + c.url().toString() + ":3:1) front is a write-once property";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(message));
+ obj->setFront(new QDeclarativeRectangle());
+
+ message = "QML Flipable (" + c.url().toString() + ":3:1) back is a write-once property";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(message));
+ obj->setBack(new QDeclarativeRectangle());
+ delete obj;
+}
+
+QTEST_MAIN(tst_qdeclarativeflipable)
+
+#include "tst_qdeclarativeflipable.moc"
diff --git a/tests/auto/declarative/qmlfontloader/data/dummy.ttf b/tests/auto/declarative/qdeclarativefontloader/data/dummy.ttf
index e69de29..e69de29 100644
--- a/tests/auto/declarative/qmlfontloader/data/dummy.ttf
+++ b/tests/auto/declarative/qdeclarativefontloader/data/dummy.ttf
diff --git a/tests/auto/declarative/qmlfontloader/data/tarzeau_ocr_a.ttf b/tests/auto/declarative/qdeclarativefontloader/data/tarzeau_ocr_a.ttf
index cf93f96..cf93f96 100644
--- a/tests/auto/declarative/qmlfontloader/data/tarzeau_ocr_a.ttf
+++ b/tests/auto/declarative/qdeclarativefontloader/data/tarzeau_ocr_a.ttf
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativefontloader/qdeclarativefontloader.pro b/tests/auto/declarative/qdeclarativefontloader/qdeclarativefontloader.pro
new file mode 100644
index 0000000..0c736b4
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativefontloader/qdeclarativefontloader.pro
@@ -0,0 +1,8 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative gui
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qdeclarativefontloader.cpp
+
+# Define SRCDIR equal to test's source directory
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qdeclarativefontloader/tst_qdeclarativefontloader.cpp b/tests/auto/declarative/qdeclarativefontloader/tst_qdeclarativefontloader.cpp
new file mode 100644
index 0000000..a9762df
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativefontloader/tst_qdeclarativefontloader.cpp
@@ -0,0 +1,156 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QtDeclarative/qdeclarativeengine.h>
+#include <QtDeclarative/qdeclarativecomponent.h>
+#include <private/qdeclarativefontloader_p.h>
+#include "../../../shared/util.h"
+
+class tst_qdeclarativefontloader : public QObject
+
+{
+ Q_OBJECT
+public:
+ tst_qdeclarativefontloader();
+
+private slots:
+ void noFont();
+ void namedFont();
+ void localFont();
+ void failLocalFont();
+ void webFont();
+ void failWebFont();
+
+private slots:
+
+private:
+ QDeclarativeEngine engine;
+};
+
+tst_qdeclarativefontloader::tst_qdeclarativefontloader()
+{
+}
+
+void tst_qdeclarativefontloader::noFont()
+{
+ QString componentStr = "import Qt 4.6\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 Qt 4.6\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 Qt 4.6\nFontLoader { source: \"" SRCDIR "/data/tarzeau_ocr_a.ttf\" }";
+ QDeclarativeComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeFontLoader *fontObject = qobject_cast<QDeclarativeFontLoader*>(component.create());
+
+ QVERIFY(fontObject != 0);
+ QVERIFY(fontObject->source() != QUrl(""));
+ QTRY_COMPARE(fontObject->name(), QString("OCRA"));
+ QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Ready);
+}
+
+void tst_qdeclarativefontloader::failLocalFont()
+{
+ QString componentStr = "import Qt 4.6\nFontLoader { source: \"" + QUrl::fromLocalFile(SRCDIR "/data/dummy.ttf").toString() + "\" }";
+ QTest::ignoreMessage(QtWarningMsg, QString("Cannot load font: QUrl( \"" + QUrl::fromLocalFile(SRCDIR "/data/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 Qt 4.6\nFontLoader { source: \"http://www.princexml.com/fonts/steffmann/Starburst.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("Starburst"));
+ QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Ready);
+}
+
+void tst_qdeclarativefontloader::failWebFont()
+{
+ QString componentStr = "import Qt 4.6\nFontLoader { source: \"http://wrong.address.com/Starburst.ttf\" }";
+ QTest::ignoreMessage(QtWarningMsg, "Cannot load font: QUrl( \"http://wrong.address.com/Starburst.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);
+}
+
+QTEST_MAIN(tst_qdeclarativefontloader)
+
+#include "tst_qdeclarativefontloader.moc"
diff --git a/tests/auto/declarative/qdeclarativegridview/data/displaygrid.qml b/tests/auto/declarative/qdeclarativegridview/data/displaygrid.qml
new file mode 100644
index 0000000..d3cdcd8
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativegridview/data/displaygrid.qml
@@ -0,0 +1,39 @@
+import Qt 4.6
+
+Rectangle {
+ width: 240
+ height: 320
+ color: "#ffffff"
+ resources: [
+ Component {
+ id: myDelegate
+ Rectangle {
+ id: wrapper
+ objectName: "wrapper"
+ width: 80
+ height: 60
+ border.color: "blue"
+ Text {
+ text: index
+ }
+ Text {
+ y: 20
+ id: displayText
+ objectName: "displayText"
+ text: display
+ }
+ color: GridView.isCurrentItem ? "lightsteelblue" : "white"
+ }
+ }
+ ]
+ GridView {
+ id: grid
+ objectName: "grid"
+ width: 240
+ height: 320
+ cellWidth: 80
+ cellHeight: 60
+ model: testModel
+ delegate: myDelegate
+ }
+}
diff --git a/tests/auto/declarative/qmlgraphicsgridview/data/gridview-initCurrent.qml b/tests/auto/declarative/qdeclarativegridview/data/gridview-initCurrent.qml
index 32833d2..32833d2 100644
--- a/tests/auto/declarative/qmlgraphicsgridview/data/gridview-initCurrent.qml
+++ b/tests/auto/declarative/qdeclarativegridview/data/gridview-initCurrent.qml
diff --git a/tests/auto/declarative/qmlgraphicsgridview/data/gridview.qml b/tests/auto/declarative/qdeclarativegridview/data/gridview.qml
index 344b4b5..344b4b5 100644
--- a/tests/auto/declarative/qmlgraphicsgridview/data/gridview.qml
+++ b/tests/auto/declarative/qdeclarativegridview/data/gridview.qml
diff --git a/tests/auto/declarative/qmlgraphicsgridview/data/gridview2.qml b/tests/auto/declarative/qdeclarativegridview/data/gridview2.qml
index 62b5bd3..62b5bd3 100644
--- a/tests/auto/declarative/qmlgraphicsgridview/data/gridview2.qml
+++ b/tests/auto/declarative/qdeclarativegridview/data/gridview2.qml
diff --git a/tests/auto/declarative/qmlgraphicsgridview/data/gridview3.qml b/tests/auto/declarative/qdeclarativegridview/data/gridview3.qml
index b133d55..b133d55 100644
--- a/tests/auto/declarative/qmlgraphicsgridview/data/gridview3.qml
+++ b/tests/auto/declarative/qdeclarativegridview/data/gridview3.qml
diff --git a/tests/auto/declarative/qdeclarativegridview/data/setindex.qml b/tests/auto/declarative/qdeclarativegridview/data/setindex.qml
new file mode 100644
index 0000000..908b365
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativegridview/data/setindex.qml
@@ -0,0 +1,33 @@
+import Qt 4.6
+
+Rectangle {
+ width: 200
+ height: 200
+ Component {
+ id: appDelegate
+
+ Item {
+ id : wrapper
+ Script {
+ function startupFunction()
+ {
+ if (index == 5) view.currentIndex = index;
+
+ }
+ }
+ Component.onCompleted: startupFunction();
+ width: 30; height: 30
+ Text { text: index }
+ }
+ }
+
+ GridView {
+ id: view
+ objectName: "grid"
+ anchors.fill: parent
+ cellWidth: 30; cellHeight: 30
+ model: 35
+ delegate: appDelegate
+ focus: true
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativegridview/qdeclarativegridview.pro b/tests/auto/declarative/qdeclarativegridview/qdeclarativegridview.pro
new file mode 100644
index 0000000..af206d7
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativegridview/qdeclarativegridview.pro
@@ -0,0 +1,8 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qdeclarativegridview.cpp
+
+# Define SRCDIR equal to test's source directory
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
new file mode 100644
index 0000000..2a60fee
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
@@ -0,0 +1,1022 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qdeclarativeengine.h>
+#include <qdeclarativecomponent.h>
+#include <QStringListModel>
+#include <QtTest/QtTest>
+#include <private/qlistmodelinterface_p.h>
+#include <qdeclarativeview.h>
+#include <private/qdeclarativegridview_p.h>
+#include <private/qdeclarativetext_p.h>
+#include <qdeclarativecontext.h>
+#include <qdeclarativeexpression.h>
+
+class tst_QDeclarativeGridView : public QObject
+{
+ Q_OBJECT
+public:
+ tst_QDeclarativeGridView();
+
+private slots:
+ void items();
+ void changed();
+ void inserted();
+ void removed();
+ void moved();
+ void changeFlow();
+ void currentIndex();
+ void defaultValues();
+ void properties();
+ void positionViewAtIndex();
+ void resetModel();
+ void QTBUG_8456();
+
+private:
+ QDeclarativeView *createView();
+ template<typename T>
+ T *findItem(QGraphicsObject *parent, const QString &id, int index=-1);
+ template<typename T>
+ QList<T*> findItems(QGraphicsObject *parent, const QString &objectName);
+ void dumpTree(QDeclarativeItem *parent, int depth = 0);
+};
+
+class TestModel : public QAbstractListModel
+{
+public:
+ enum Roles { Name = Qt::UserRole+1, Number = Qt::UserRole+2 };
+
+ TestModel(QObject *parent=0) : QAbstractListModel(parent) {
+ QHash<int, QByteArray> roles;
+ roles[Name] = "name";
+ roles[Number] = "number";
+ setRoleNames(roles);
+ }
+
+ int rowCount(const QModelIndex &parent=QModelIndex()) const { return list.count(); }
+ QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) 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 count() const { return rowCount(); }
+ QString name(int index) const { return list.at(index).first; }
+ QString number(int index) const { return list.at(index).second; }
+
+ void addItem(const QString &name, const QString &number) {
+ emit beginInsertRows(QModelIndex(), list.count(), list.count());
+ list.append(QPair<QString,QString>(name, number));
+ emit endInsertRows();
+ }
+
+ void 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 removeItem(int index) {
+ emit beginRemoveRows(QModelIndex(), index, index);
+ list.removeAt(index);
+ emit endRemoveRows();
+ }
+
+ void moveItem(int from, int to) {
+ emit beginMoveRows(QModelIndex(), from, from, QModelIndex(), to);
+ list.move(from, to);
+ emit endMoveRows();
+ }
+
+ void modifyItem(int idx, const QString &name, const QString &number) {
+ list[idx] = QPair<QString,QString>(name, number);
+ emit dataChanged(index(idx,0), index(idx,0));
+ }
+
+private:
+ QList<QPair<QString,QString> > list;
+};
+
+tst_QDeclarativeGridView::tst_QDeclarativeGridView()
+{
+}
+
+void tst_QDeclarativeGridView::items()
+{
+ QDeclarativeView *canvas = createView();
+
+ TestModel 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("testTopToBottom", QVariant(false));
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/gridview.qml"));
+ qApp->processEvents();
+
+ QDeclarativeGridView *gridview = findItem<QDeclarativeGridView>(canvas->rootObject(), "grid");
+ QVERIFY(gridview != 0);
+
+ QDeclarativeItem *viewport = gridview->viewport();
+ QVERIFY(viewport != 0);
+
+ QCOMPARE(gridview->count(), model.count());
+ QCOMPARE(viewport->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
+
+ for (int i = 0; i < model.count(); ++i) {
+ QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", i);
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), model.name(i));
+ QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", i);
+ QVERIFY(number != 0);
+ QCOMPARE(number->text(), model.number(i));
+ }
+
+ // set an empty model and confirm that items are destroyed
+ TestModel model2;
+ ctxt->setContextProperty("testModel", &model2);
+
+ int itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ QVERIFY(itemCount == 0);
+
+ delete canvas;
+}
+
+void tst_QDeclarativeGridView::changed()
+{
+ QDeclarativeView *canvas = createView();
+
+ TestModel 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("testTopToBottom", QVariant(false));
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/gridview.qml"));
+ qApp->processEvents();
+
+ QDeclarativeFlickable *gridview = findItem<QDeclarativeFlickable>(canvas->rootObject(), "grid");
+ QVERIFY(gridview != 0);
+
+ QDeclarativeItem *viewport = gridview->viewport();
+ QVERIFY(viewport != 0);
+
+ model.modifyItem(1, "Will", "9876");
+ QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", 1);
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), model.name(1));
+ QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", 1);
+ QVERIFY(number != 0);
+ QCOMPARE(number->text(), model.number(1));
+
+ delete canvas;
+}
+
+void tst_QDeclarativeGridView::inserted()
+{
+ QDeclarativeView *canvas = createView();
+
+ TestModel model;
+ model.addItem("Fred", "12345");
+ model.addItem("John", "2345");
+ model.addItem("Bob", "54321");
+
+ QDeclarativeContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("testTopToBottom", QVariant(false));
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/gridview.qml"));
+ qApp->processEvents();
+
+ QDeclarativeGridView *gridview = findItem<QDeclarativeGridView>(canvas->rootObject(), "grid");
+ QVERIFY(gridview != 0);
+
+ QDeclarativeItem *viewport = gridview->viewport();
+ QVERIFY(viewport != 0);
+
+ model.insertItem(1, "Will", "9876");
+
+ // let transitions settle.
+ QTest::qWait(300);
+
+ QCOMPARE(viewport->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
+
+ QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", 1);
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), model.name(1));
+ QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", 1);
+ QVERIFY(number != 0);
+ QCOMPARE(number->text(), model.number(1));
+
+ // Confirm items positioned correctly
+ for (int i = 0; i < model.count(); ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QCOMPARE(item->x(), (i%3)*80.0);
+ QCOMPARE(item->y(), (i/3)*60.0);
+ }
+
+ model.insertItem(0, "Foo", "1111"); // zero index, and current item
+
+ // let transitions settle.
+ QTest::qWait(300);
+
+ QCOMPARE(viewport->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
+
+ name = findItem<QDeclarativeText>(viewport, "textName", 0);
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), model.name(0));
+ number = findItem<QDeclarativeText>(viewport, "textNumber", 0);
+ QVERIFY(number != 0);
+ QCOMPARE(number->text(), model.number(0));
+
+ QCOMPARE(gridview->currentIndex(), 1);
+
+ // Confirm items positioned correctly
+ for (int i = 0; i < model.count(); ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QVERIFY(item->x() == (i%3)*80);
+ QVERIFY(item->y() == (i/3)*60);
+ }
+
+ for (int i = model.count(); i < 30; ++i)
+ model.insertItem(i, "Hello", QString::number(i));
+ QTest::qWait(300);
+
+ gridview->setContentY(120);
+ QTest::qWait(300);
+
+ // Insert item outside visible area
+ model.insertItem(1, "Hello", "1324");
+ QTest::qWait(300);
+
+ QVERIFY(gridview->contentY() == 120);
+
+ delete canvas;
+}
+
+void tst_QDeclarativeGridView::removed()
+{
+ QDeclarativeView *canvas = createView();
+
+ TestModel model;
+ for (int i = 0; i < 40; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QDeclarativeContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("testTopToBottom", QVariant(false));
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/gridview.qml"));
+ qApp->processEvents();
+
+ QDeclarativeGridView *gridview = findItem<QDeclarativeGridView>(canvas->rootObject(), "grid");
+ QVERIFY(gridview != 0);
+
+ QDeclarativeItem *viewport = gridview->viewport();
+ QVERIFY(viewport != 0);
+
+ model.removeItem(1);
+
+ // let transitions settle.
+ QTest::qWait(300);
+
+ QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", 1);
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), model.name(1));
+ QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", 1);
+ QVERIFY(number != 0);
+ QCOMPARE(number->text(), model.number(1));
+
+ // Confirm items positioned correctly
+ int itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QVERIFY(item);
+ QVERIFY(item->x() == (i%3)*80);
+ QVERIFY(item->y() == (i/3)*60);
+ }
+
+ // Remove first item (which is the current item);
+ model.removeItem(0);
+
+ // let transitions settle.
+ QTest::qWait(300);
+
+ name = findItem<QDeclarativeText>(viewport, "textName", 0);
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), model.name(0));
+ number = findItem<QDeclarativeText>(viewport, "textNumber", 0);
+ QVERIFY(number != 0);
+ QCOMPARE(number->text(), model.number(0));
+
+ // Confirm items positioned correctly
+ itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QVERIFY(item);
+ QVERIFY(item->x() == (i%3)*80);
+ QVERIFY(item->y() == (i/3)*60);
+ }
+
+ // Remove items not visible
+ model.removeItem(25);
+ // let transitions settle.
+ QTest::qWait(300);
+
+ // Confirm items positioned correctly
+ itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QVERIFY(item);
+ QVERIFY(item->x() == (i%3)*80);
+ QVERIFY(item->y() == (i/3)*60);
+ }
+
+ // Remove items before visible
+ gridview->setContentY(120);
+ QTest::qWait(500);
+ gridview->setCurrentIndex(10);
+
+ // let transitions settle.
+ QTest::qWait(300);
+
+ // Setting currentIndex above shouldn't cause view to scroll
+ QCOMPARE(gridview->contentY(), 120.0);
+
+ model.removeItem(1);
+
+ // let transitions settle.
+ QTest::qWait(300);
+
+ // Confirm items positioned correctly
+ for (int i = 6; i < 18; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QVERIFY(item);
+ QVERIFY(item->x() == (i%3)*80);
+ QVERIFY(item->y() == (i/3)*60);
+ }
+
+ // Remove currentIndex
+ QDeclarativeItem *oldCurrent = gridview->currentItem();
+ model.removeItem(9);
+ QTest::qWait(500);
+
+ QCOMPARE(gridview->currentIndex(), 9);
+ QVERIFY(gridview->currentItem() != oldCurrent);
+
+ gridview->setContentY(0);
+ // let transitions settle.
+ QTest::qWait(300);
+
+ // Confirm items positioned correctly
+ itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QVERIFY(item);
+ QVERIFY(item->x() == (i%3)*80);
+ QVERIFY(item->y() == (i/3)*60);
+ }
+
+ // remove item outside current view.
+ gridview->setCurrentIndex(32);
+ QTest::qWait(500);
+ gridview->setContentY(240);
+
+ model.removeItem(30);
+ QVERIFY(gridview->currentIndex() == 31);
+
+ // remove current item beyond visible items.
+ gridview->setCurrentIndex(20);
+ QTest::qWait(500);
+ gridview->setContentY(0);
+ model.removeItem(20);
+ QTest::qWait(500);
+
+ QCOMPARE(gridview->currentIndex(), 20);
+ QVERIFY(gridview->currentItem() != 0);
+
+ // remove item before current, but visible
+ gridview->setCurrentIndex(8);
+ QTest::qWait(500);
+ gridview->setContentY(240);
+ oldCurrent = gridview->currentItem();
+ model.removeItem(6);
+ QTest::qWait(500);
+
+ QCOMPARE(gridview->currentIndex(), 7);
+ QVERIFY(gridview->currentItem() == oldCurrent);
+
+ delete canvas;
+}
+
+void tst_QDeclarativeGridView::moved()
+{
+ QDeclarativeView *canvas = createView();
+
+ TestModel model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QDeclarativeContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("testTopToBottom", QVariant(false));
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/gridview.qml"));
+ qApp->processEvents();
+
+ QDeclarativeGridView *gridview = findItem<QDeclarativeGridView>(canvas->rootObject(), "grid");
+ QVERIFY(gridview != 0);
+
+ QDeclarativeItem *viewport = gridview->viewport();
+ QVERIFY(viewport != 0);
+
+ model.moveItem(1, 8);
+
+ // let transitions settle.
+ QTest::qWait(300);
+
+ QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", 1);
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), model.name(1));
+ QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", 1);
+ QVERIFY(number != 0);
+ QCOMPARE(number->text(), model.number(1));
+
+ name = findItem<QDeclarativeText>(viewport, "textName", 8);
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), model.name(8));
+ number = findItem<QDeclarativeText>(viewport, "textNumber", 8);
+ QVERIFY(number != 0);
+ QCOMPARE(number->text(), model.number(8));
+
+ // Confirm items positioned correctly
+ int itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QVERIFY(item);
+ QVERIFY(item->x() == (i%3)*80);
+ QVERIFY(item->y() == (i/3)*60);
+ }
+
+ gridview->setContentY(120);
+
+ // move outside visible area
+ model.moveItem(1, 25);
+
+ // let transitions settle.
+ QTest::qWait(300);
+
+ // Confirm items positioned correctly and indexes correct
+ itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count()-1;
+ for (int i = 6; i < model.count()-6 && i < itemCount+6; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QVERIFY(item);
+ QCOMPARE(item->x(), qreal((i%3)*80));
+ QCOMPARE(item->y(), qreal((i/3)*60));
+ name = findItem<QDeclarativeText>(viewport, "textName", i);
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), model.name(i));
+ number = findItem<QDeclarativeText>(viewport, "textNumber", i);
+ QVERIFY(number != 0);
+ QCOMPARE(number->text(), model.number(i));
+ }
+
+ // move from outside visible into visible
+ model.moveItem(28, 8);
+
+ // let transitions settle.
+ QTest::qWait(300);
+
+ // Confirm items positioned correctly and indexes correct
+ for (int i = 6; i < model.count()-6 && i < itemCount+6; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QVERIFY(item);
+ QVERIFY(item->x() == (i%3)*80);
+ QVERIFY(item->y() == (i/3)*60);
+ name = findItem<QDeclarativeText>(viewport, "textName", i);
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), model.name(i));
+ number = findItem<QDeclarativeText>(viewport, "textNumber", i);
+ QVERIFY(number != 0);
+ QCOMPARE(number->text(), model.number(i));
+ }
+
+ delete canvas;
+}
+
+void tst_QDeclarativeGridView::currentIndex()
+{
+ TestModel model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), QString::number(i));
+
+ QDeclarativeView *canvas = new QDeclarativeView(0);
+ canvas->setFixedSize(240,320);
+
+ QDeclarativeContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ QString filename(SRCDIR "/data/gridview-initCurrent.qml");
+ canvas->setSource(QUrl::fromLocalFile(filename));
+
+ qApp->processEvents();
+
+ QDeclarativeGridView *gridview = findItem<QDeclarativeGridView>(canvas->rootObject(), "grid");
+ QVERIFY(gridview != 0);
+
+ QDeclarativeItem *viewport = gridview->viewport();
+ QVERIFY(viewport != 0);
+
+ QTest::qWait(500);
+
+ // current item should be third item
+ QCOMPARE(gridview->currentIndex(), 5);
+ QCOMPARE(gridview->currentItem(), findItem<QDeclarativeItem>(viewport, "wrapper", 5));
+ QCOMPARE(gridview->currentItem()->y(), gridview->highlightItem()->y());
+
+ gridview->moveCurrentIndexRight();
+ QCOMPARE(gridview->currentIndex(), 6);
+ gridview->moveCurrentIndexDown();
+ QCOMPARE(gridview->currentIndex(), 9);
+ gridview->moveCurrentIndexUp();
+ QCOMPARE(gridview->currentIndex(), 6);
+ gridview->moveCurrentIndexLeft();
+ QCOMPARE(gridview->currentIndex(), 5);
+
+ // no wrap
+ gridview->setCurrentIndex(0);
+ QCOMPARE(gridview->currentIndex(), 0);
+
+ gridview->moveCurrentIndexUp();
+ QCOMPARE(gridview->currentIndex(), 0);
+
+ gridview->moveCurrentIndexLeft();
+ QCOMPARE(gridview->currentIndex(), 0);
+
+ gridview->setCurrentIndex(model.count()-1);
+ QTest::qWait(500);
+ 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);
+ QTest::qWait(500);
+
+ gridview->moveCurrentIndexLeft();
+ QCOMPARE(gridview->currentIndex(), model.count()-1);
+
+ QTest::qWait(500);
+ QCOMPARE(gridview->contentY(), 279.0);
+
+ gridview->moveCurrentIndexRight();
+ QCOMPARE(gridview->currentIndex(), 0);
+
+ QTest::qWait(500);
+ QCOMPARE(gridview->contentY(), 0.0);
+
+ // Test keys
+ qApp->setActiveWindow(canvas);
+ canvas->show();
+ canvas->setFocus();
+ qApp->processEvents();
+
+ QTest::keyClick(canvas, Qt::Key_Down);
+ QCOMPARE(gridview->currentIndex(), 3);
+
+ QTest::keyClick(canvas, Qt::Key_Up);
+ QCOMPARE(gridview->currentIndex(), 0);
+
+ gridview->setFlow(QDeclarativeGridView::TopToBottom);
+
+ QEXPECT_FAIL("", "QTBUG-8475", Abort);
+ 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);
+
+
+ // turn off auto highlight
+ gridview->setHighlightFollowsCurrentItem(false);
+ QVERIFY(gridview->highlightFollowsCurrentItem() == false);
+
+ QTest::qWait(500);
+ QVERIFY(gridview->highlightItem());
+ qreal hlPosX = gridview->highlightItem()->x();
+ qreal hlPosY = gridview->highlightItem()->y();
+
+ gridview->setCurrentIndex(5);
+ QTest::qWait(500);
+ QCOMPARE(gridview->highlightItem()->x(), hlPosX);
+ QCOMPARE(gridview->highlightItem()->y(), hlPosY);
+
+ delete canvas;
+}
+
+void tst_QDeclarativeGridView::changeFlow()
+{
+ QDeclarativeView *canvas = createView();
+
+ TestModel 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("testTopToBottom", QVariant(false));
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/gridview.qml"));
+ qApp->processEvents();
+
+ QDeclarativeGridView *gridview = findItem<QDeclarativeGridView>(canvas->rootObject(), "grid");
+ QVERIFY(gridview != 0);
+
+ QDeclarativeItem *viewport = gridview->viewport();
+ QVERIFY(viewport != 0);
+
+ // Confirm items positioned correctly and indexes correct
+ int itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QVERIFY(item);
+ QCOMPARE(item->x(), qreal((i%3)*80));
+ QCOMPARE(item->y(), qreal((i/3)*60));
+ QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", i);
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), model.name(i));
+ QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", i);
+ QVERIFY(number != 0);
+ QCOMPARE(number->text(), model.number(i));
+ }
+
+ ctxt->setContextProperty("testTopToBottom", QVariant(true));
+ QTest::qWait(500);
+
+ // Confirm items positioned correctly and indexes correct
+ itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QVERIFY(item);
+ QCOMPARE(item->x(), qreal((i/5)*80));
+ QCOMPARE(item->y(), qreal((i%5)*60));
+ QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", i);
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), model.name(i));
+ QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", i);
+ QVERIFY(number != 0);
+ QCOMPARE(number->text(), model.number(i));
+ }
+
+ delete canvas;
+}
+
+void tst_QDeclarativeGridView::defaultValues()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/gridview3.qml"));
+ QDeclarativeGridView *obj = qobject_cast<QDeclarativeGridView*>(c.create());
+
+ QVERIFY(obj != 0);
+ QVERIFY(obj->model() == QVariant());
+ QVERIFY(obj->delegate() == 0);
+ QCOMPARE(obj->currentIndex(), -1);
+ QVERIFY(obj->currentItem() == 0);
+ QCOMPARE(obj->count(), 0);
+ QVERIFY(obj->highlight() == 0);
+ QVERIFY(obj->highlightItem() == 0);
+ QCOMPARE(obj->highlightFollowsCurrentItem(), true);
+ QVERIFY(obj->flow() == 0);
+ QCOMPARE(obj->isWrapEnabled(), false);
+ QCOMPARE(obj->cacheBuffer(), 0);
+ QCOMPARE(obj->cellWidth(), 100); //### Should 100 be the default?
+ QCOMPARE(obj->cellHeight(), 100);
+ delete obj;
+}
+
+void tst_QDeclarativeGridView::properties()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/gridview2.qml"));
+ QDeclarativeGridView *obj = qobject_cast<QDeclarativeGridView*>(c.create());
+
+ QVERIFY(obj != 0);
+ QVERIFY(obj->model() != QVariant());
+ QVERIFY(obj->delegate() != 0);
+ QCOMPARE(obj->currentIndex(), 0);
+ QVERIFY(obj->currentItem() != 0);
+ QCOMPARE(obj->count(), 4);
+ QVERIFY(obj->highlight() != 0);
+ QVERIFY(obj->highlightItem() != 0);
+ QCOMPARE(obj->highlightFollowsCurrentItem(), false);
+ QVERIFY(obj->flow() == 0);
+ QCOMPARE(obj->isWrapEnabled(), true);
+ QCOMPARE(obj->cacheBuffer(), 200);
+ QCOMPARE(obj->cellWidth(), 100);
+ QCOMPARE(obj->cellHeight(), 100);
+ delete obj;
+}
+
+void tst_QDeclarativeGridView::positionViewAtIndex()
+{
+ QDeclarativeView *canvas = createView();
+
+ TestModel model;
+ for (int i = 0; i < 40; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QDeclarativeContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("testTopToBottom", QVariant(false));
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/gridview.qml"));
+ qApp->processEvents();
+
+ QDeclarativeGridView *gridview = findItem<QDeclarativeGridView>(canvas->rootObject(), "grid");
+ QVERIFY(gridview != 0);
+
+ QDeclarativeItem *viewport = gridview->viewport();
+ QVERIFY(viewport != 0);
+
+ // Confirm items positioned correctly
+ int itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount-1; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QVERIFY(item);
+ QCOMPARE(item->x(), (i%3)*80.);
+ QCOMPARE(item->y(), (i/3)*60.);
+ }
+
+ // Position on a currently visible item
+ gridview->positionViewAtIndex(4);
+ QCOMPARE(gridview->contentY(), 60.);
+
+ // Confirm items positioned correctly
+ itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ for (int i = 3; i < model.count() && i < itemCount-3-1; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QVERIFY(item);
+ QCOMPARE(item->x(), (i%3)*80.);
+ QCOMPARE(item->y(), (i/3)*60.);
+ }
+
+ // Position on an item beyond the visible items
+ gridview->positionViewAtIndex(21);
+ QCOMPARE(gridview->contentY(), 420.);
+
+ // Confirm items positioned correctly
+ itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ for (int i = 22; i < model.count() && i < itemCount-22-1; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QVERIFY(item);
+ QCOMPARE(item->x(), (i%3)*80.);
+ QCOMPARE(item->y(), (i/3)*60.);
+ }
+
+ // Position on an item that would leave empty space if positioned at the top
+ gridview->positionViewAtIndex(31);
+ QCOMPARE(gridview->contentY(), 520.);
+
+ // Confirm items positioned correctly
+ itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ for (int i = 24; i < model.count() && i < itemCount-24-1; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QVERIFY(item);
+ QCOMPARE(item->x(), (i%3)*80.);
+ QCOMPARE(item->y(), (i/3)*60.);
+ }
+
+ // Position at the beginning again
+ gridview->positionViewAtIndex(0);
+ QCOMPARE(gridview->contentY(), 0.);
+
+ // Confirm items positioned correctly
+ itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount-1; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QVERIFY(item);
+ QCOMPARE(item->x(), (i%3)*80.);
+ QCOMPARE(item->y(), (i/3)*60.);
+ }
+
+ delete canvas;
+}
+
+void tst_QDeclarativeGridView::resetModel()
+{
+ QDeclarativeView *canvas = createView();
+
+ QStringList strings;
+ strings << "one" << "two" << "three";
+ QStringListModel model(strings);
+
+ QDeclarativeContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/displaygrid.qml"));
+ qApp->processEvents();
+
+ QDeclarativeGridView *gridview = findItem<QDeclarativeGridView>(canvas->rootObject(), "grid");
+ QVERIFY(gridview != 0);
+
+ QDeclarativeItem *viewport = gridview->viewport();
+ QVERIFY(viewport != 0);
+
+ QCOMPARE(gridview->count(), model.rowCount());
+
+ for (int i = 0; i < model.rowCount(); ++i) {
+ QDeclarativeText *display = findItem<QDeclarativeText>(viewport, "displayText", i);
+ QVERIFY(display != 0);
+ QCOMPARE(display->text(), strings.at(i));
+ }
+
+ strings.clear();
+ strings << "four" << "five" << "six" << "seven";
+ model.setStringList(strings);
+
+ QCOMPARE(gridview->count(), model.rowCount());
+
+ for (int i = 0; i < model.rowCount(); ++i) {
+ QDeclarativeText *display = findItem<QDeclarativeText>(viewport, "displayText", i);
+ QVERIFY(display != 0);
+ QCOMPARE(display->text(), strings.at(i));
+ }
+}
+
+void tst_QDeclarativeGridView::QTBUG_8456()
+{
+ QDeclarativeView *canvas = createView();
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/setindex.qml"));
+ qApp->processEvents();
+
+ QDeclarativeGridView *gridview = findItem<QDeclarativeGridView>(canvas->rootObject(), "grid");
+ QVERIFY(gridview != 0);
+
+ QCOMPARE(gridview->currentIndex(), 0);
+}
+
+QDeclarativeView *tst_QDeclarativeGridView::createView()
+{
+ QDeclarativeView *canvas = new QDeclarativeView(0);
+ canvas->setFixedSize(240,320);
+
+ return canvas;
+}
+
+/*
+ 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 *tst_QDeclarativeGridView::findItem(QGraphicsObject *parent, const QString &objectName, int index)
+{
+ const QMetaObject &mo = T::staticMetaObject;
+ //qDebug() << parent->childItems().count() << "children";
+ for (int i = 0; i < parent->childItems().count(); ++i) {
+ QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(parent->childItems().at(i));
+ if(!item)
+ continue;
+ //qDebug() << "try" << item;
+ if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) {
+ if (index != -1) {
+ QDeclarativeContext *context = QDeclarativeEngine::contextForObject(item);
+ if (context) {
+ if (context->contextProperty("index").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*> tst_QDeclarativeGridView::findItems(QGraphicsObject *parent, const QString &objectName)
+{
+ QList<T*> items;
+ const QMetaObject &mo = T::staticMetaObject;
+ //qDebug() << parent->childItems().count() << "children";
+ for (int i = 0; i < parent->childItems().count(); ++i) {
+ QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(parent->childItems().at(i));
+ if(!item)
+ continue;
+ //qDebug() << "try" << item;
+ if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) {
+ items.append(static_cast<T*>(item));
+ //qDebug() << " found:" << item;
+ }
+ items += findItems<T>(item, objectName);
+ }
+
+ return items;
+}
+
+void tst_QDeclarativeGridView::dumpTree(QDeclarativeItem *parent, int depth)
+{
+ static QString padding(" ");
+ for (int i = 0; i < parent->childItems().count(); ++i) {
+ QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(parent->childItems().at(i));
+ if(!item)
+ continue;
+ QDeclarativeContext *context = QDeclarativeEngine::contextForObject(item);
+ qDebug() << padding.left(depth*2) << item << (context ? context->contextProperty("index").toInt() : -1);
+ dumpTree(item, depth+1);
+ }
+}
+
+
+QTEST_MAIN(tst_QDeclarativeGridView)
+
+#include "tst_qdeclarativegridview.moc"
diff --git a/tests/auto/declarative/qmlgraphicsimage/data/colors.png b/tests/auto/declarative/qdeclarativeimage/data/colors.png
index dfb62f3..dfb62f3 100644
--- a/tests/auto/declarative/qmlgraphicsimage/data/colors.png
+++ b/tests/auto/declarative/qdeclarativeimage/data/colors.png
Binary files differ
diff --git a/tests/auto/declarative/qmlgraphicsborderimage/data/colors.png b/tests/auto/declarative/qdeclarativeimage/data/colors1.png
index dfb62f3..dfb62f3 100644
--- a/tests/auto/declarative/qmlgraphicsborderimage/data/colors.png
+++ b/tests/auto/declarative/qdeclarativeimage/data/colors1.png
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativeimage/qdeclarativeimage.pro b/tests/auto/declarative/qdeclarativeimage/qdeclarativeimage.pro
new file mode 100644
index 0000000..7634c12
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeimage/qdeclarativeimage.pro
@@ -0,0 +1,9 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative gui network
+macx:CONFIG -= app_bundle
+
+HEADERS += ../shared/testhttpserver.h
+SOURCES += tst_qdeclarativeimage.cpp ../shared/testhttpserver.cpp
+
+# Define SRCDIR equal to test's source directory
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp
new file mode 100644
index 0000000..ed2095b
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp
@@ -0,0 +1,253 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QTextDocument>
+#include <QTcpServer>
+#include <QTcpSocket>
+#include <QDir>
+
+#include <QtDeclarative/qdeclarativeengine.h>
+#include <QtDeclarative/qdeclarativecomponent.h>
+#include <private/qdeclarativeimage_p.h>
+#include <private/qdeclarativeimagebase_p.h>
+#include <private/qdeclarativeloader_p.h>
+#include <QtDeclarative/qdeclarativecontext.h>
+
+#include "../shared/testhttpserver.h"
+
+
+#define SERVER_PORT 14445
+#define SERVER_ADDR "http://127.0.0.1:14445"
+
+#define TRY_WAIT(expr) \
+ do { \
+ for (int ii = 0; ii < 60; ++ii) { \
+ if ((expr)) break; \
+ QTest::qWait(50); \
+ } \
+ QVERIFY((expr)); \
+ } while (false)
+
+
+class tst_qdeclarativeimage : public QObject
+
+{
+ Q_OBJECT
+public:
+ tst_qdeclarativeimage();
+
+private slots:
+ void noSource();
+ void imageSource();
+ void imageSource_data();
+ void clearSource();
+ void resized();
+ void smooth();
+ void pixmap();
+
+private:
+ QDeclarativeEngine engine;
+};
+
+tst_qdeclarativeimage::tst_qdeclarativeimage()
+{
+}
+
+void tst_qdeclarativeimage::noSource()
+{
+ QString componentStr = "import Qt 4.6\nImage { source: \"\" }";
+ QDeclarativeComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeImage *obj = qobject_cast<QDeclarativeImage*>(component.create());
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->source(), QUrl());
+ QVERIFY(obj->status() == QDeclarativeImage::Null);
+ QCOMPARE(obj->width(), 0.);
+ QCOMPARE(obj->height(), 0.);
+ QCOMPARE(obj->fillMode(), QDeclarativeImage::Stretch);
+ QCOMPARE(obj->progress(), 0.0);
+
+ delete obj;
+}
+
+void tst_qdeclarativeimage::imageSource_data()
+{
+ QTest::addColumn<QString>("source");
+ QTest::addColumn<bool>("remote");
+ QTest::addColumn<bool>("async");
+ QTest::addColumn<QString>("error");
+
+ QTest::newRow("local") << QUrl::fromLocalFile(SRCDIR "/data/colors.png").toString() << false << false << "";
+ QTest::newRow("local async") << QUrl::fromLocalFile(SRCDIR "/data/colors1.png").toString() << false << true << "";
+ QTest::newRow("local not found") << QUrl::fromLocalFile(SRCDIR "/data/no-such-file.png").toString() << false
+ << false << "Cannot open QUrl( \"" + QUrl::fromLocalFile(SRCDIR "/data/no-such-file.png").toString() + "\" ) ";
+ QTest::newRow("local async not found") << QUrl::fromLocalFile(SRCDIR "/data/no-such-file-1.png").toString() << false
+ << true << "\"Cannot open: " + QUrl::fromLocalFile(SRCDIR "/data/no-such-file-1.png").toString() + "\" ";
+ QTest::newRow("remote") << SERVER_ADDR "/colors.png" << true << false << "";
+ QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.png" << true << false
+ << "\"Error downloading " SERVER_ADDR "/no-such-file.png - server replied: Not found\" ";
+}
+
+void tst_qdeclarativeimage::imageSource()
+{
+ QFETCH(QString, source);
+ QFETCH(bool, remote);
+ QFETCH(bool, async);
+ QFETCH(QString, error);
+
+ TestHTTPServer server(SERVER_PORT);
+ if (remote) {
+ QVERIFY(server.isValid());
+ server.serveDirectory(SRCDIR "/data");
+ }
+
+ if (!error.isEmpty())
+ QTest::ignoreMessage(QtWarningMsg, error.toUtf8());
+
+ QString componentStr = "import Qt 4.6\nImage { source: \"" + source + "\"; asynchronous: "
+ + (async ? QLatin1String("true") : QLatin1String("false")) + " }";
+ QDeclarativeComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeImage *obj = qobject_cast<QDeclarativeImage*>(component.create());
+ QVERIFY(obj != 0);
+
+ if (remote || async)
+ TRY_WAIT(obj->status() == QDeclarativeImage::Loading);
+
+ QCOMPARE(obj->source(), remote ? source : QUrl(source));
+
+ if (error.isEmpty()) {
+ TRY_WAIT(obj->status() == QDeclarativeImage::Ready);
+ QCOMPARE(obj->width(), 120.);
+ QCOMPARE(obj->height(), 120.);
+ QCOMPARE(obj->fillMode(), QDeclarativeImage::Stretch);
+ QCOMPARE(obj->progress(), 1.0);
+ } else {
+ TRY_WAIT(obj->status() == QDeclarativeImage::Error);
+ }
+
+ delete obj;
+}
+
+void tst_qdeclarativeimage::clearSource()
+{
+ QString componentStr = "import Qt 4.6\nImage { source: srcImage }";
+ QDeclarativeContext *ctxt = engine.rootContext();
+ ctxt->setContextProperty("srcImage", QUrl::fromLocalFile(SRCDIR "/data/colors.png"));
+ QDeclarativeComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeImage *obj = qobject_cast<QDeclarativeImage*>(component.create());
+ QVERIFY(obj != 0);
+ QVERIFY(obj->status() == QDeclarativeImage::Ready);
+ QCOMPARE(obj->width(), 120.);
+ QCOMPARE(obj->height(), 120.);
+ QCOMPARE(obj->progress(), 1.0);
+
+ ctxt->setContextProperty("srcImage", "");
+ QVERIFY(obj->source().isEmpty());
+ QVERIFY(obj->status() == QDeclarativeImage::Null);
+ QCOMPARE(obj->width(), 0.);
+ QCOMPARE(obj->height(), 0.);
+ QCOMPARE(obj->progress(), 0.0);
+}
+
+void tst_qdeclarativeimage::resized()
+{
+ QString componentStr = "import Qt 4.6\nImage { source: \"" SRCDIR "/data/colors.png\"; width: 300; height: 300 }";
+ QDeclarativeComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeImage *obj = qobject_cast<QDeclarativeImage*>(component.create());
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->width(), 300.);
+ QCOMPARE(obj->height(), 300.);
+ QCOMPARE(obj->fillMode(), QDeclarativeImage::Stretch);
+
+ delete obj;
+}
+
+void tst_qdeclarativeimage::smooth()
+{
+ QString componentStr = "import Qt 4.6\nImage { source: \"" SRCDIR "/data/colors.png\"; smooth: true; width: 300; height: 300 }";
+ QDeclarativeComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeImage *obj = qobject_cast<QDeclarativeImage*>(component.create());
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->width(), 300.);
+ QCOMPARE(obj->height(), 300.);
+ QCOMPARE(obj->smooth(), true);
+ QCOMPARE(obj->fillMode(), QDeclarativeImage::Stretch);
+
+ delete obj;
+}
+
+void tst_qdeclarativeimage::pixmap()
+{
+ QString componentStr = "import Qt 4.6\nImage { pixmap: testPixmap }";
+
+ QPixmap pixmap;
+ QDeclarativeContext *ctxt = engine.rootContext();
+ ctxt->setContextProperty("testPixmap", pixmap);
+
+ QDeclarativeComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+
+ QDeclarativeImage *obj = qobject_cast<QDeclarativeImage*>(component.create());
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->source(), QUrl());
+ QVERIFY(obj->status() == QDeclarativeImage::Null);
+ QCOMPARE(obj->width(), 0.);
+ QCOMPARE(obj->height(), 0.);
+ QCOMPARE(obj->fillMode(), QDeclarativeImage::Stretch);
+ QCOMPARE(obj->progress(), 0.0);
+ QVERIFY(obj->pixmap().isNull());
+
+ pixmap = QPixmap(SRCDIR "/data/colors.png");
+ ctxt->setContextProperty("testPixmap", pixmap);
+ QCOMPARE(obj->width(), 120.);
+ QCOMPARE(obj->height(), 120.);
+ QVERIFY(obj->status() == QDeclarativeImage::Ready);
+
+ delete obj;
+}
+
+QTEST_MAIN(tst_qdeclarativeimage)
+
+#include "tst_qdeclarativeimage.moc"
diff --git a/tests/auto/declarative/qmlpixmapcache/data/exists.png b/tests/auto/declarative/qdeclarativeimageprovider/data/exists.png
index 399bd0b..399bd0b 100644
--- a/tests/auto/declarative/qmlpixmapcache/data/exists.png
+++ b/tests/auto/declarative/qdeclarativeimageprovider/data/exists.png
Binary files differ
diff --git a/tests/auto/declarative/qmlpixmapcache/data/exists1.png b/tests/auto/declarative/qdeclarativeimageprovider/data/exists1.png
index 399bd0b..399bd0b 100644
--- a/tests/auto/declarative/qmlpixmapcache/data/exists1.png
+++ b/tests/auto/declarative/qdeclarativeimageprovider/data/exists1.png
Binary files differ
diff --git a/tests/auto/declarative/qmlpixmapcache/data/exists2.png b/tests/auto/declarative/qdeclarativeimageprovider/data/exists2.png
index 399bd0b..399bd0b 100644
--- a/tests/auto/declarative/qmlpixmapcache/data/exists2.png
+++ b/tests/auto/declarative/qdeclarativeimageprovider/data/exists2.png
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativeimageprovider/qdeclarativeimageprovider.pro b/tests/auto/declarative/qdeclarativeimageprovider/qdeclarativeimageprovider.pro
new file mode 100644
index 0000000..a4d3eb2
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeimageprovider/qdeclarativeimageprovider.pro
@@ -0,0 +1,12 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative
+QT += network
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qdeclarativeimageprovider.cpp
+
+# QMAKE_CXXFLAGS = -fprofile-arcs -ftest-coverage
+# LIBS += -lgcov
+
+# Define SRCDIR equal to test's source directory
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp b/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp
new file mode 100644
index 0000000..c5bdfc8
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp
@@ -0,0 +1,166 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QtTest/QtTest>
+#include <QtDeclarative/qdeclarativeengine.h>
+#include <QtDeclarative/qdeclarativeimageprovider.h>
+#include <private/qdeclarativeimage_p.h>
+
+// QDeclarativeImageProvider::request() is run in an idle thread where possible
+// Be generous in our timeout.
+#define TRY_WAIT(expr) \
+ do { \
+ for (int ii = 0; ii < 10; ++ii) { \
+ if ((expr)) break; \
+ QTest::qWait(100); \
+ } \
+ QVERIFY((expr)); \
+ } while (false)
+
+
+class tst_qdeclarativeimageprovider : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qdeclarativeimageprovider()
+ {
+ }
+
+private slots:
+ void imageSource();
+ void imageSource_data();
+ void removeProvider();
+
+private:
+ QDeclarativeEngine engine;
+};
+
+class TestProvider : public QDeclarativeImageProvider
+{
+public:
+ QImage request(const QString &id) {
+ QImage image;
+ image.load(SRCDIR "/data/" + id);
+ return image;
+ }
+};
+
+void tst_qdeclarativeimageprovider::imageSource_data()
+{
+ QTest::addColumn<QString>("source");
+ QTest::addColumn<QString>("error");
+
+ QTest::newRow("exists") << "image://test/exists.png" << "";
+ QTest::newRow("missing") << "image://test/no-such-file.png"
+ << "\"Failed to get image from provider: image://test/no-such-file.png\" ";
+ QTest::newRow("unknown provider") << "image://bogus/exists.png"
+ << "\"Failed to get image from provider: image://bogus/exists.png\" ";
+}
+
+void tst_qdeclarativeimageprovider::imageSource()
+{
+ QFETCH(QString, source);
+ QFETCH(QString, error);
+
+ if (!error.isEmpty())
+ QTest::ignoreMessage(QtWarningMsg, error.toUtf8());
+
+ engine.addImageProvider("test", new TestProvider);
+ QVERIFY(engine.imageProvider("test") != 0);
+
+ QString componentStr = "import Qt 4.6\nImage { source: \"" + source + "\" }";
+ QDeclarativeComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeImage *obj = qobject_cast<QDeclarativeImage*>(component.create());
+ QVERIFY(obj != 0);
+
+ TRY_WAIT(obj->status() == QDeclarativeImage::Loading);
+
+ QCOMPARE(obj->source(), QUrl(source));
+
+ if (error.isEmpty()) {
+ TRY_WAIT(obj->status() == QDeclarativeImage::Ready);
+ QCOMPARE(obj->width(), 100.);
+ QCOMPARE(obj->height(), 100.);
+ QCOMPARE(obj->fillMode(), QDeclarativeImage::Stretch);
+ QCOMPARE(obj->progress(), 1.0);
+ } else {
+ TRY_WAIT(obj->status() == QDeclarativeImage::Error);
+ }
+
+ delete obj;
+}
+
+void tst_qdeclarativeimageprovider::removeProvider()
+{
+ engine.addImageProvider("test2", new TestProvider);
+ QVERIFY(engine.imageProvider("test2") != 0);
+
+ // add provider, confirm it works
+ QString componentStr = "import Qt 4.6\nImage { source: \"image://test2/exists1.png\" }";
+ QDeclarativeComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeImage *obj = qobject_cast<QDeclarativeImage*>(component.create());
+ QVERIFY(obj != 0);
+
+ TRY_WAIT(obj->status() == QDeclarativeImage::Loading);
+ TRY_WAIT(obj->status() == QDeclarativeImage::Ready);
+
+ QCOMPARE(obj->width(), 100.0);
+
+ // remove the provider and confirm
+ QString error("\"Failed to get image from provider: image://test2/exists2.png\" ");
+ QTest::ignoreMessage(QtWarningMsg, error.toUtf8());
+
+ engine.removeImageProvider("test2");
+
+ obj->setSource(QUrl("image://test2/exists2.png"));
+
+ TRY_WAIT(obj->status() == QDeclarativeImage::Loading);
+ TRY_WAIT(obj->status() == QDeclarativeImage::Error);
+
+ delete obj;
+}
+
+
+QTEST_MAIN(tst_qdeclarativeimageprovider)
+
+#include "tst_qdeclarativeimageprovider.moc"
diff --git a/tests/auto/declarative/qmlinfo/data/NestedObject.qml b/tests/auto/declarative/qdeclarativeinfo/data/NestedObject.qml
index cd5b426..cd5b426 100644
--- a/tests/auto/declarative/qmlinfo/data/NestedObject.qml
+++ b/tests/auto/declarative/qdeclarativeinfo/data/NestedObject.qml
diff --git a/tests/auto/declarative/qmlinfo/data/nestedQmlObject.qml b/tests/auto/declarative/qdeclarativeinfo/data/nestedQmlObject.qml
index a2ce78a..a2ce78a 100644
--- a/tests/auto/declarative/qmlinfo/data/nestedQmlObject.qml
+++ b/tests/auto/declarative/qdeclarativeinfo/data/nestedQmlObject.qml
diff --git a/tests/auto/declarative/qmlinfo/data/qmlObject.qml b/tests/auto/declarative/qdeclarativeinfo/data/qmlObject.qml
index ce05f89..ce05f89 100644
--- a/tests/auto/declarative/qmlinfo/data/qmlObject.qml
+++ b/tests/auto/declarative/qdeclarativeinfo/data/qmlObject.qml
diff --git a/tests/auto/declarative/qdeclarativeinfo/qdeclarativeinfo.pro b/tests/auto/declarative/qdeclarativeinfo/qdeclarativeinfo.pro
new file mode 100644
index 0000000..015c094
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeinfo/qdeclarativeinfo.pro
@@ -0,0 +1,7 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qdeclarativeinfo.cpp
+
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qdeclarativeinfo/tst_qdeclarativeinfo.cpp b/tests/auto/declarative/qdeclarativeinfo/tst_qdeclarativeinfo.cpp
new file mode 100644
index 0000000..aa3f03b
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeinfo/tst_qdeclarativeinfo.cpp
@@ -0,0 +1,139 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+#include <QDeclarativeEngine>
+#include <QDeclarativeComponent>
+#include <QPushButton>
+#include <QDeclarativeContext>
+#include <qdeclarativeinfo.h>
+
+class tst_qdeclarativeinfo : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qdeclarativeinfo() {}
+
+private slots:
+ void qmlObject();
+ void nestedQmlObject();
+ void nonQmlObject();
+ void nullObject();
+ void nonQmlContextedObject();
+
+private:
+ QDeclarativeEngine engine;
+};
+
+inline QUrl TEST_FILE(const QString &filename)
+{
+ return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename);
+}
+
+void tst_qdeclarativeinfo::qmlObject()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("qmlObject.qml"));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QString message = "QML QObject_QML_0 (" + component.url().toString() + ":3:1) Test Message";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(message));
+ qmlInfo(object) << "Test Message";
+
+ QObject *nested = qvariant_cast<QObject *>(object->property("nested"));
+ QVERIFY(nested != 0);
+
+ message = "QML QtObject (" + component.url().toString() + ":6:13) Second Test Message";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(message));
+ qmlInfo(nested) << "Second Test Message";
+}
+
+void tst_qdeclarativeinfo::nestedQmlObject()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("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 = "QML NestedObject (" + component.url().toString() + ":5:13) Outer Object";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(message));
+ qmlInfo(nested) << "Outer Object";
+
+ message = "QML QtObject (" + TEST_FILE("NestedObject.qml").toString() + ":6:14) Inner Object";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(message));
+ qmlInfo(nested2) << "Inner Object";
+}
+
+void tst_qdeclarativeinfo::nonQmlObject()
+{
+ QObject object;
+ QTest::ignoreMessage(QtWarningMsg, "QML QtObject (unknown location) Test Message");
+ qmlInfo(&object) << "Test Message";
+
+ QPushButton pbObject;
+ QTest::ignoreMessage(QtWarningMsg, "QML QPushButton (unknown location) Test Message");
+ qmlInfo(&pbObject) << "Test Message";
+}
+
+void tst_qdeclarativeinfo::nullObject()
+{
+ QTest::ignoreMessage(QtWarningMsg, "QML (unknown location) 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, "QML QtObject (unknown location) Test Message");
+ qmlInfo(&object) << "Test Message";
+}
+
+QTEST_MAIN(tst_qdeclarativeinfo)
+
+#include "tst_qdeclarativeinfo.moc"
diff --git a/tests/auto/declarative/qdeclarativeinstruction/qdeclarativeinstruction.pro b/tests/auto/declarative/qdeclarativeinstruction/qdeclarativeinstruction.pro
new file mode 100644
index 0000000..b8f7d27
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeinstruction/qdeclarativeinstruction.pro
@@ -0,0 +1,6 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative script
+SOURCES += tst_qdeclarativeinstruction.cpp
+macx:CONFIG -= app_bundle
+
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp b/tests/auto/declarative/qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp
new file mode 100644
index 0000000..636c5e3
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp
@@ -0,0 +1,585 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+#include <private/qdeclarativecompiler_p.h>
+
+class tst_qdeclarativeinstruction : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qdeclarativeinstruction() {}
+
+private slots:
+ void dump();
+};
+
+static QStringList messages;
+static void msgHandler(QtMsgType, const char *msg)
+{
+ messages << QLatin1String(msg);
+}
+
+void tst_qdeclarativeinstruction::dump()
+{
+ QDeclarativeCompiledData *data = new QDeclarativeCompiledData(0);
+ {
+ QDeclarativeInstruction i;
+ i.line = 0;
+ i.type = QDeclarativeInstruction::Init;
+ i.init.bindingsSize = 0;
+ i.init.parserStatusSize = 3;
+ i.init.contextCache = -1;
+ i.init.compiledBinding = -1;
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeCompiledData::TypeReference ref;
+ ref.className = "Test";
+ data->types << ref;
+
+ QDeclarativeInstruction i;
+ i.line = 1;
+ i.type = QDeclarativeInstruction::CreateObject;
+ i.create.type = 0;
+ i.create.data = -1;
+ i.create.bindingBits = -1;
+ i.create.column = 10;
+ data->bytecode << i;
+ }
+
+ {
+ data->primitives << "testId";
+
+ QDeclarativeInstruction i;
+ i.line = 2;
+ i.type = QDeclarativeInstruction::SetId;
+ i.setId.value = 0;
+ i.setId.index = 0;
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = 3;
+ i.type = QDeclarativeInstruction::SetDefault;
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = 4;
+ i.type = QDeclarativeInstruction::CreateComponent;
+ i.createComponent.count = 3;
+ i.createComponent.column = 4;
+ i.createComponent.endLine = 14;
+ i.createComponent.metaObject = 0;
+
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = 5;
+ i.type = QDeclarativeInstruction::StoreMetaObject;
+ i.storeMeta.data = 3;
+ i.storeMeta.aliasData = 6;
+ i.storeMeta.propertyCache = 7;
+
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = 6;
+ i.type = QDeclarativeInstruction::StoreFloat;
+ i.storeFloat.propertyIndex = 3;
+ i.storeFloat.value = 11.3;
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = 7;
+ i.type = QDeclarativeInstruction::StoreDouble;
+ i.storeDouble.propertyIndex = 4;
+ i.storeDouble.value = 14.8;
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = 8;
+ i.type = QDeclarativeInstruction::StoreInteger;
+ i.storeInteger.propertyIndex = 5;
+ i.storeInteger.value = 9;
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = 9;
+ i.type = QDeclarativeInstruction::StoreBool;
+ i.storeBool.propertyIndex = 6;
+ i.storeBool.value = true;
+
+ data->bytecode << i;
+ }
+
+ {
+ data->primitives << "Test String";
+ QDeclarativeInstruction i;
+ i.line = 10;
+ i.type = QDeclarativeInstruction::StoreString;
+ i.storeString.propertyIndex = 7;
+ i.storeString.value = 1;
+ data->bytecode << i;
+ }
+
+ {
+ data->primitives << "http://www.nokia.com";
+ QDeclarativeInstruction i;
+ i.line = 11;
+ i.type = QDeclarativeInstruction::StoreUrl;
+ i.storeUrl.propertyIndex = 8;
+ i.storeUrl.value = 2;
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = 12;
+ i.type = QDeclarativeInstruction::StoreColor;
+ i.storeColor.propertyIndex = 9;
+ i.storeColor.value = 0xFF00FF00;
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = 13;
+ i.type = QDeclarativeInstruction::StoreDate;
+ i.storeDate.propertyIndex = 10;
+ i.storeDate.value = 9;
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = 14;
+ i.type = QDeclarativeInstruction::StoreTime;
+ i.storeTime.propertyIndex = 11;
+ i.storeTime.valueIndex = 33;
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = 15;
+ i.type = QDeclarativeInstruction::StoreDateTime;
+ i.storeDateTime.propertyIndex = 12;
+ i.storeDateTime.valueIndex = 44;
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = 16;
+ i.type = QDeclarativeInstruction::StorePoint;
+ i.storeRealPair.propertyIndex = 13;
+ i.storeRealPair.valueIndex = 3;
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = 17;
+ i.type = QDeclarativeInstruction::StorePointF;
+ i.storeRealPair.propertyIndex = 14;
+ i.storeRealPair.valueIndex = 9;
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = 18;
+ i.type = QDeclarativeInstruction::StoreSize;
+ i.storeRealPair.propertyIndex = 15;
+ i.storeRealPair.valueIndex = 8;
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = 19;
+ i.type = QDeclarativeInstruction::StoreSizeF;
+ i.storeRealPair.propertyIndex = 16;
+ i.storeRealPair.valueIndex = 99;
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = 20;
+ i.type = QDeclarativeInstruction::StoreRect;
+ i.storeRect.propertyIndex = 17;
+ i.storeRect.valueIndex = 2;
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = 21;
+ i.type = QDeclarativeInstruction::StoreRectF;
+ i.storeRect.propertyIndex = 18;
+ i.storeRect.valueIndex = 19;
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = 22;
+ i.type = QDeclarativeInstruction::StoreVector3D;
+ i.storeVector3D.propertyIndex = 19;
+ i.storeVector3D.valueIndex = 9;
+ data->bytecode << i;
+ }
+
+ {
+ data->primitives << "color(1, 1, 1, 1)";
+ QDeclarativeInstruction i;
+ i.line = 23;
+ i.type = QDeclarativeInstruction::StoreVariant;
+ i.storeString.propertyIndex = 20;
+ i.storeString.value = 3;
+
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = 24;
+ i.type = QDeclarativeInstruction::StoreObject;
+ i.storeObject.propertyIndex = 21;
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = 25;
+ i.type = QDeclarativeInstruction::StoreVariantObject;
+ i.storeObject.propertyIndex = 22;
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = 26;
+ i.type = QDeclarativeInstruction::StoreInterface;
+ i.storeObject.propertyIndex = 23;
+ data->bytecode << i;
+ }
+
+ {
+ data->primitives << "console.log(1921)";
+
+ QDeclarativeInstruction i;
+ i.line = 27;
+ i.type = QDeclarativeInstruction::StoreSignal;
+ i.storeSignal.signalIndex = 2;
+ i.storeSignal.value = 4;
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = 28;
+ i.type = QDeclarativeInstruction::StoreScript;
+ i.storeScript.value = 2;
+ //i.storeScript.fileName = 18;
+ //i.storeScript.lineNumber = 28;
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = 29;
+ i.type = QDeclarativeInstruction::StoreScriptString;
+ i.storeScriptString.propertyIndex = 24;
+ i.storeScriptString.value = 3;
+ i.storeScriptString.scope = 1;
+ data->bytecode << i;
+ }
+
+ {
+ data->datas << "mySignal";
+
+ QDeclarativeInstruction i;
+ i.line = 30;
+ i.type = QDeclarativeInstruction::AssignSignalObject;
+ i.assignSignalObject.signal = 0;
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = 31;
+ i.type = QDeclarativeInstruction::AssignCustomType;
+ i.assignCustomType.propertyIndex = 25;
+ i.assignCustomType.valueIndex = 4;
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = 32;
+ i.type = QDeclarativeInstruction::StoreBinding;
+ i.assignBinding.property = 26;
+ i.assignBinding.value = 3;
+ i.assignBinding.context = 2;
+ i.assignBinding.owner = 0;
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = 33;
+ i.type = QDeclarativeInstruction::StoreCompiledBinding;
+ i.assignBinding.property = 27;
+ i.assignBinding.value = 2;
+ i.assignBinding.context = 4;
+ i.assignBinding.owner = 0;
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = 34;
+ i.type = QDeclarativeInstruction::StoreValueSource;
+ i.assignValueSource.property = 29;
+ i.assignValueSource.owner = 1;
+ i.assignValueSource.castValue = 4;
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = 35;
+ i.type = QDeclarativeInstruction::StoreValueInterceptor;
+ i.assignValueInterceptor.property = 30;
+ i.assignValueInterceptor.owner = 2;
+ i.assignValueInterceptor.castValue = -4;
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = 36;
+ i.type = QDeclarativeInstruction::BeginObject;
+ i.begin.castValue = 4;
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = 38;
+ i.type = QDeclarativeInstruction::StoreObjectQList;
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = 39;
+ i.type = QDeclarativeInstruction::AssignObjectList;
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = 40;
+ i.type = QDeclarativeInstruction::FetchAttached;
+ i.fetchAttached.id = 23;
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = 42;
+ i.type = QDeclarativeInstruction::FetchQList;
+ i.fetch.property = 32;
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = 43;
+ i.type = QDeclarativeInstruction::FetchObject;
+ i.fetch.property = 33;
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = 44;
+ i.type = QDeclarativeInstruction::FetchValueType;
+ i.fetchValue.property = 34;
+ i.fetchValue.type = 6;
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = 45;
+ i.type = QDeclarativeInstruction::PopFetchedObject;
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = 46;
+ i.type = QDeclarativeInstruction::PopQList;
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = 47;
+ i.type = QDeclarativeInstruction::PopValueType;
+ i.fetchValue.property = 35;
+ i.fetchValue.type = 8;
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = 48;
+ i.type = QDeclarativeInstruction::Defer;
+ i.defer.deferCount = 7;
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = -1;
+ i.type = QDeclarativeInstruction::Defer;
+ i.defer.deferCount = 7;
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = 50;
+ i.type = (QDeclarativeInstruction::Type)(QDeclarativeInstruction::Defer + 1); // Non-existant
+ data->bytecode << i;
+ }
+
+ QStringList expect;
+ expect
+ << "Index\tLine\tOperation\t\tData1\tData2\tData3\tComments"
+ << "-------------------------------------------------------------------------------"
+ << "0\t\t0\tINIT\t\t\t0\t3\t-1\t-1"
+ << "1\t\t1\tCREATE\t\t\t0\t\t\t\"Test\""
+ << "2\t\t2\tSETID\t\t\t0\t\t\t\"testId\""
+ << "3\t\t3\tSET_DEFAULT"
+ << "4\t\t4\tCREATE_COMPONENT\t3"
+ << "5\t\t5\tSTORE_META\t\t3"
+ << "6\t\t6\tSTORE_FLOAT\t\t3\t11.3"
+ << "7\t\t7\tSTORE_DOUBLE\t\t4\t14.8"
+ << "8\t\t8\tSTORE_INTEGER\t\t5\t9"
+ << "9\t\t9\tSTORE_BOOL\t\t6\ttrue"
+ << "10\t\t10\tSTORE_STRING\t\t7\t1\t\t\"Test String\""
+ << "11\t\t11\tSTORE_URL\t\t8\t2\t\t\"http://www.nokia.com\""
+ << "12\t\t12\tSTORE_COLOR\t\t9\t\t\t\"ff00ff00\""
+ << "13\t\t13\tSTORE_DATE\t\t10\t9"
+ << "14\t\t14\tSTORE_TIME\t\t11\t33"
+ << "15\t\t15\tSTORE_DATETIME\t\t12\t44"
+ << "16\t\t16\tSTORE_POINT\t\t13\t3"
+ << "17\t\t17\tSTORE_POINTF\t\t14\t9"
+ << "18\t\t18\tSTORE_SIZE\t\t15\t8"
+ << "19\t\t19\tSTORE_SIZEF\t\t16\t99"
+ << "20\t\t20\tSTORE_RECT\t\t17\t2"
+ << "21\t\t21\tSTORE_RECTF\t\t18\t19"
+ << "22\t\t22\tSTORE_VECTOR3D\t\t19\t9"
+ << "23\t\t23\tSTORE_VARIANT\t\t20\t3\t\t\"color(1, 1, 1, 1)\""
+ << "24\t\t24\tSTORE_OBJECT\t\t21"
+ << "25\t\t25\tSTORE_VARIANT_OBJECT\t22"
+ << "26\t\t26\tSTORE_INTERFACE\t\t23"
+ << "27\t\t27\tSTORE_SIGNAL\t\t2\t4\t\t\"console.log(1921)\""
+ << "28\t\t28\tSTORE_SCRIPT\t\t2"
+ << "29\t\t29\tSTORE_SCRIPT_STRING\t24\t3\t1"
+ << "30\t\t30\tASSIGN_SIGNAL_OBJECT\t0\t\t\t\"mySignal\""
+ << "31\t\t31\tASSIGN_CUSTOMTYPE\t25\t4"
+ << "32\t\t32\tSTORE_BINDING\t26\t3\t2"
+ << "33\t\t33\tSTORE_COMPILED_BINDING\t27\t2\t4"
+ << "34\t\t34\tSTORE_VALUE_SOURCE\t29\t4"
+ << "35\t\t35\tSTORE_VALUE_INTERCEPTOR\t30\t-4"
+ << "36\t\t36\tBEGIN\t\t\t4"
+ << "37\t\t38\tSTORE_OBJECT_QLIST"
+ << "38\t\t39\tASSIGN_OBJECT_LIST"
+ << "39\t\t40\tFETCH_ATTACHED\t\t23"
+ << "40\t\t42\tFETCH_QLIST\t\t32"
+ << "41\t\t43\tFETCH\t\t\t33"
+ << "42\t\t44\tFETCH_VALUE\t\t34\t6"
+ << "43\t\t45\tPOP"
+ << "44\t\t46\tPOP_QLIST"
+ << "45\t\t47\tPOP_VALUE\t\t35\t8"
+ << "46\t\t48\tDEFER\t\t\t7"
+ << "47\t\tNA\tDEFER\t\t\t7"
+ << "48\t\t50\tXXX UNKOWN INSTRUCTION\t47"
+ << "-------------------------------------------------------------------------------";
+
+ 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();
+}
+
+QTEST_MAIN(tst_qdeclarativeinstruction)
+
+#include "tst_qdeclarativeinstruction.moc"
diff --git a/tests/auto/declarative/qmlgraphicsitem/data/keynavigation.qml b/tests/auto/declarative/qdeclarativeitem/data/keynavigation.qml
index 9281a17..9281a17 100644
--- a/tests/auto/declarative/qmlgraphicsitem/data/keynavigation.qml
+++ b/tests/auto/declarative/qdeclarativeitem/data/keynavigation.qml
diff --git a/tests/auto/declarative/qmlgraphicsitem/data/keys.qml b/tests/auto/declarative/qdeclarativeitem/data/keys.qml
index f3c1f7b..f3c1f7b 100644
--- a/tests/auto/declarative/qmlgraphicsitem/data/keys.qml
+++ b/tests/auto/declarative/qdeclarativeitem/data/keys.qml
diff --git a/tests/auto/declarative/qdeclarativeitem/qdeclarativeitem.pro b/tests/auto/declarative/qdeclarativeitem/qdeclarativeitem.pro
new file mode 100644
index 0000000..0eb2141
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeitem/qdeclarativeitem.pro
@@ -0,0 +1,7 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative gui
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qdeclarativeitem.cpp
+
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp
new file mode 100644
index 0000000..36dcf1f
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp
@@ -0,0 +1,318 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QtTest/QSignalSpy>
+#include <QtDeclarative/qdeclarativeengine.h>
+#include <QtDeclarative/qdeclarativecomponent.h>
+#include <QtDeclarative/qdeclarativecontext.h>
+#include <QtDeclarative/qdeclarativeview.h>
+#include <QtDeclarative/qdeclarativeitem.h>
+
+class tst_QDeclarativeItem : public QObject
+
+{
+ Q_OBJECT
+public:
+ tst_QDeclarativeItem();
+
+private slots:
+ void keys();
+ void keyNavigation();
+ void smooth();
+ void clip();
+
+private:
+ template<typename T>
+ T *findItem(QGraphicsObject *parent, const QString &objectName);
+ QDeclarativeEngine engine;
+};
+
+class KeysTestObject : public QObject
+{
+ Q_OBJECT
+public:
+ KeysTestObject() : mKey(0), mModifiers(0), mForwardedKey(0) {}
+
+ void reset() {
+ mKey = 0;
+ mText = QString();
+ mModifiers = 0;
+ mForwardedKey = 0;
+ }
+
+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;
+ }
+
+public:
+ int mKey;
+ QString mText;
+ int mModifiers;
+ int mForwardedKey;
+
+private:
+};
+
+
+tst_QDeclarativeItem::tst_QDeclarativeItem()
+{
+}
+
+void tst_QDeclarativeItem::keys()
+{
+ QDeclarativeView *canvas = new QDeclarativeView(0);
+ canvas->setFixedSize(240,320);
+
+ KeysTestObject *testObject = new KeysTestObject;
+ canvas->rootContext()->setContextProperty("keysTestObject", testObject);
+
+ canvas->rootContext()->setContextProperty("enableKeyHanding", QVariant(true));
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/keys.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QEvent wa(QEvent::WindowActivate);
+ QApplication::sendEvent(canvas, &wa);
+ QFocusEvent fe(QEvent::FocusIn);
+ QApplication::sendEvent(canvas, &fe);
+
+ QKeyEvent key(QEvent::KeyPress, Qt::Key_A, Qt::NoModifier, "A", false, 1);
+ QApplication::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);
+ QApplication::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);
+ QApplication::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);
+ QApplication::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);
+ QApplication::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();
+
+ canvas->rootContext()->setContextProperty("enableKeyHanding", QVariant(false));
+
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Return, Qt::NoModifier, "", false, 1);
+ QApplication::sendEvent(canvas, &key);
+ QCOMPARE(testObject->mKey, 0);
+ QVERIFY(!key.isAccepted());
+
+ delete canvas;
+ delete testObject;
+}
+
+void tst_QDeclarativeItem::keyNavigation()
+{
+ QDeclarativeView *canvas = new QDeclarativeView(0);
+ canvas->setFixedSize(240,320);
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/keynavigation.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QEvent wa(QEvent::WindowActivate);
+ QApplication::sendEvent(canvas, &wa);
+ QFocusEvent fe(QEvent::FocusIn);
+ QApplication::sendEvent(canvas, &fe);
+
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(canvas->rootObject(), "item1");
+ QVERIFY(item);
+ QVERIFY(item->hasFocus());
+
+ // right
+ QKeyEvent key(QEvent::KeyPress, Qt::Key_Right, Qt::NoModifier, "", false, 1);
+ QApplication::sendEvent(canvas, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QDeclarativeItem>(canvas->rootObject(), "item2");
+ QVERIFY(item);
+ QVERIFY(item->hasFocus());
+
+ // down
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Down, Qt::NoModifier, "", false, 1);
+ QApplication::sendEvent(canvas, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QDeclarativeItem>(canvas->rootObject(), "item4");
+ QVERIFY(item);
+ QVERIFY(item->hasFocus());
+
+ // left
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Left, Qt::NoModifier, "", false, 1);
+ QApplication::sendEvent(canvas, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QDeclarativeItem>(canvas->rootObject(), "item3");
+ QVERIFY(item);
+ QVERIFY(item->hasFocus());
+
+ // up
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Up, Qt::NoModifier, "", false, 1);
+ QApplication::sendEvent(canvas, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QDeclarativeItem>(canvas->rootObject(), "item1");
+ QVERIFY(item);
+ QVERIFY(item->hasFocus());
+}
+
+void tst_QDeclarativeItem::smooth()
+{
+ QDeclarativeComponent component(&engine);
+ component.setData("import Qt 4.6; Item { smooth: false; }", QUrl::fromLocalFile(""));
+ QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(component.create());
+ QSignalSpy spy(item, SIGNAL(smoothChanged()));
+
+ QVERIFY(item);
+ QVERIFY(!item->smooth());
+
+ item->setSmooth(true);
+ QVERIFY(item->smooth());
+ QCOMPARE(spy.count(),1);
+ item->setSmooth(true);
+ QCOMPARE(spy.count(),1);
+
+ item->setSmooth(false);
+ QVERIFY(!item->smooth());
+ QCOMPARE(spy.count(),2);
+ item->setSmooth(false);
+ QCOMPARE(spy.count(),2);
+}
+
+void tst_QDeclarativeItem::clip()
+{
+ QDeclarativeComponent component(&engine);
+ component.setData("import Qt 4.6\nItem { clip: false\n }", QUrl::fromLocalFile(""));
+ QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(component.create());
+ QSignalSpy spy(item, SIGNAL(clipChanged()));
+
+ QVERIFY(item);
+ QVERIFY(!item->clip());
+
+ item->setClip(true);
+ QVERIFY(item->clip());
+ 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);
+}
+
+template<typename T>
+T *tst_QDeclarativeItem::findItem(QGraphicsObject *parent, const QString &objectName)
+{
+ if (!parent)
+ return 0;
+
+ const QMetaObject &mo = T::staticMetaObject;
+ //qDebug() << parent->QGraphicsObject::children().count() << "children";
+ for (int i = 0; i < parent->childItems().count(); ++i) {
+ QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(parent->childItems().at(i));
+ if(!item)
+ continue;
+ //qDebug() << "try" << item;
+ if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName))
+ return static_cast<T*>(item);
+ item = findItem<T>(item, objectName);
+ if (item)
+ return static_cast<T*>(item);
+ }
+
+ return 0;
+}
+
+
+
+QTEST_MAIN(tst_QDeclarativeItem)
+
+#include "tst_qdeclarativeitem.moc"
diff --git a/tests/auto/declarative/qmllanguage/data/Alias.qml b/tests/auto/declarative/qdeclarativelanguage/data/Alias.qml
index 55aa231..55aa231 100644
--- a/tests/auto/declarative/qmllanguage/data/Alias.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/Alias.qml
diff --git a/tests/auto/declarative/qmllanguage/data/Alias2.qml b/tests/auto/declarative/qdeclarativelanguage/data/Alias2.qml
index 6362b2d..6362b2d 100644
--- a/tests/auto/declarative/qmllanguage/data/Alias2.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/Alias2.qml
diff --git a/tests/auto/declarative/qmllanguage/data/Alias3.qml b/tests/auto/declarative/qdeclarativelanguage/data/Alias3.qml
index d1e78f8..d1e78f8 100644
--- a/tests/auto/declarative/qmllanguage/data/Alias3.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/Alias3.qml
diff --git a/tests/auto/declarative/qmllanguage/data/Alias4.qml b/tests/auto/declarative/qdeclarativelanguage/data/Alias4.qml
index 573674c..573674c 100644
--- a/tests/auto/declarative/qmllanguage/data/Alias4.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/Alias4.qml
diff --git a/tests/auto/declarative/qmllanguage/data/ComponentComposite.qml b/tests/auto/declarative/qdeclarativelanguage/data/ComponentComposite.qml
index 05fbc3f..05fbc3f 100644
--- a/tests/auto/declarative/qmllanguage/data/ComponentComposite.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/ComponentComposite.qml
diff --git a/tests/auto/declarative/qmllanguage/data/CompositeType.qml b/tests/auto/declarative/qdeclarativelanguage/data/CompositeType.qml
index 99d010f..99d010f 100644
--- a/tests/auto/declarative/qmllanguage/data/CompositeType.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/CompositeType.qml
diff --git a/tests/auto/declarative/qmllanguage/data/CompositeType2.qml b/tests/auto/declarative/qdeclarativelanguage/data/CompositeType2.qml
index 86210e9..86210e9 100644
--- a/tests/auto/declarative/qmllanguage/data/CompositeType2.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/CompositeType2.qml
diff --git a/tests/auto/declarative/qmllanguage/data/CompositeType3.qml b/tests/auto/declarative/qdeclarativelanguage/data/CompositeType3.qml
index d08f35b..d08f35b 100644
--- a/tests/auto/declarative/qmllanguage/data/CompositeType3.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/CompositeType3.qml
diff --git a/tests/auto/declarative/qmllanguage/data/CompositeType4.qml b/tests/auto/declarative/qdeclarativelanguage/data/CompositeType4.qml
index a6a8168..a6a8168 100644
--- a/tests/auto/declarative/qmllanguage/data/CompositeType4.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/CompositeType4.qml
diff --git a/tests/auto/declarative/qmllanguage/data/DynamicPropertiesNestedType.qml b/tests/auto/declarative/qdeclarativelanguage/data/DynamicPropertiesNestedType.qml
index aefbf9a..aefbf9a 100644
--- a/tests/auto/declarative/qmllanguage/data/DynamicPropertiesNestedType.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/DynamicPropertiesNestedType.qml
diff --git a/tests/auto/declarative/qmllanguage/data/HelperAlias.qml b/tests/auto/declarative/qdeclarativelanguage/data/HelperAlias.qml
index dc3b382..dc3b382 100644
--- a/tests/auto/declarative/qmllanguage/data/HelperAlias.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/HelperAlias.qml
diff --git a/tests/auto/declarative/qmllanguage/data/I18n.qml b/tests/auto/declarative/qdeclarativelanguage/data/I18n.qml
index 558c836..558c836 100644
--- a/tests/auto/declarative/qmllanguage/data/I18n.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/I18n.qml
diff --git a/tests/auto/declarative/qmllanguage/data/I18nType30.qml b/tests/auto/declarative/qdeclarativelanguage/data/I18nType30.qml
index 42dbc69..42dbc69 100644
--- a/tests/auto/declarative/qmllanguage/data/I18nType30.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/I18nType30.qml
diff --git a/tests/auto/declarative/qmllanguage/data/MyComponent.qml b/tests/auto/declarative/qdeclarativelanguage/data/MyComponent.qml
index 1a23277..1a23277 100644
--- a/tests/auto/declarative/qmllanguage/data/MyComponent.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/MyComponent.qml
diff --git a/tests/auto/declarative/qmllanguage/data/MyCompositeValueSource.qml b/tests/auto/declarative/qdeclarativelanguage/data/MyCompositeValueSource.qml
index e620e26..e620e26 100644
--- a/tests/auto/declarative/qmllanguage/data/MyCompositeValueSource.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/MyCompositeValueSource.qml
diff --git a/tests/auto/declarative/qmllanguage/data/MyContainerComponent.qml b/tests/auto/declarative/qdeclarativelanguage/data/MyContainerComponent.qml
index 61f54c5..61f54c5 100644
--- a/tests/auto/declarative/qmllanguage/data/MyContainerComponent.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/MyContainerComponent.qml
diff --git a/tests/auto/declarative/qmllanguage/data/NestedAlias.qml b/tests/auto/declarative/qdeclarativelanguage/data/NestedAlias.qml
index 5155612..5155612 100644
--- a/tests/auto/declarative/qmllanguage/data/NestedAlias.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/NestedAlias.qml
diff --git a/tests/auto/declarative/qmllanguage/data/NestedErrorsType.qml b/tests/auto/declarative/qdeclarativelanguage/data/NestedErrorsType.qml
index 5cc8d20..5cc8d20 100644
--- a/tests/auto/declarative/qmllanguage/data/NestedErrorsType.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/NestedErrorsType.qml
diff --git a/tests/auto/declarative/qmllanguage/data/OnCompletedType.qml b/tests/auto/declarative/qdeclarativelanguage/data/OnCompletedType.qml
index 2889caf..2889caf 100644
--- a/tests/auto/declarative/qmllanguage/data/OnCompletedType.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/OnCompletedType.qml
diff --git a/tests/auto/declarative/qmllanguage/data/alias.1.qml b/tests/auto/declarative/qdeclarativelanguage/data/alias.1.qml
index 500b0f6..500b0f6 100644
--- a/tests/auto/declarative/qmllanguage/data/alias.1.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/alias.1.qml
diff --git a/tests/auto/declarative/qmllanguage/data/alias.2.qml b/tests/auto/declarative/qdeclarativelanguage/data/alias.2.qml
index 5c92270..5c92270 100644
--- a/tests/auto/declarative/qmllanguage/data/alias.2.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/alias.2.qml
diff --git a/tests/auto/declarative/qmllanguage/data/alias.3.qml b/tests/auto/declarative/qdeclarativelanguage/data/alias.3.qml
index e059937..e059937 100644
--- a/tests/auto/declarative/qmllanguage/data/alias.3.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/alias.3.qml
diff --git a/tests/auto/declarative/qmllanguage/data/alias.4.qml b/tests/auto/declarative/qdeclarativelanguage/data/alias.4.qml
index bd6a769..bd6a769 100644
--- a/tests/auto/declarative/qmllanguage/data/alias.4.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/alias.4.qml
diff --git a/tests/auto/declarative/qmllanguage/data/alias.5.qml b/tests/auto/declarative/qdeclarativelanguage/data/alias.5.qml
index 4316d0d..4316d0d 100644
--- a/tests/auto/declarative/qmllanguage/data/alias.5.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/alias.5.qml
diff --git a/tests/auto/declarative/qmllanguage/data/alias.6.qml b/tests/auto/declarative/qdeclarativelanguage/data/alias.6.qml
index e3af230..e3af230 100644
--- a/tests/auto/declarative/qmllanguage/data/alias.6.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/alias.6.qml
diff --git a/tests/auto/declarative/qmllanguage/data/alias.7.qml b/tests/auto/declarative/qdeclarativelanguage/data/alias.7.qml
index a9a57eb..a9a57eb 100644
--- a/tests/auto/declarative/qmllanguage/data/alias.7.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/alias.7.qml
diff --git a/tests/auto/declarative/qmllanguage/data/alias.8.qml b/tests/auto/declarative/qdeclarativelanguage/data/alias.8.qml
index 2b9ad85..2b9ad85 100644
--- a/tests/auto/declarative/qmllanguage/data/alias.8.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/alias.8.qml
diff --git a/tests/auto/declarative/qmllanguage/data/alias.9.qml b/tests/auto/declarative/qdeclarativelanguage/data/alias.9.qml
index a2a41a1..a2a41a1 100644
--- a/tests/auto/declarative/qmllanguage/data/alias.9.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/alias.9.qml
diff --git a/tests/auto/declarative/qmllanguage/data/assignBasicTypes.qml b/tests/auto/declarative/qdeclarativelanguage/data/assignBasicTypes.qml
index c86c96b..c86c96b 100644
--- a/tests/auto/declarative/qmllanguage/data/assignBasicTypes.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/assignBasicTypes.qml
diff --git a/tests/auto/declarative/qmllanguage/data/assignCompositeToType.qml b/tests/auto/declarative/qdeclarativelanguage/data/assignCompositeToType.qml
index f6422bd..f6422bd 100644
--- a/tests/auto/declarative/qmllanguage/data/assignCompositeToType.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/assignCompositeToType.qml
diff --git a/tests/auto/declarative/qmllanguage/data/assignLiteralSignalProperty.qml b/tests/auto/declarative/qdeclarativelanguage/data/assignLiteralSignalProperty.qml
index 399fcea..399fcea 100644
--- a/tests/auto/declarative/qmllanguage/data/assignLiteralSignalProperty.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/assignLiteralSignalProperty.qml
diff --git a/tests/auto/declarative/qmllanguage/data/assignObjectToSignal.qml b/tests/auto/declarative/qdeclarativelanguage/data/assignObjectToSignal.qml
index 789cc66..789cc66 100644
--- a/tests/auto/declarative/qmllanguage/data/assignObjectToSignal.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/assignObjectToSignal.qml
diff --git a/tests/auto/declarative/qmllanguage/data/assignObjectToVariant.qml b/tests/auto/declarative/qdeclarativelanguage/data/assignObjectToVariant.qml
index 0ff9370..0ff9370 100644
--- a/tests/auto/declarative/qmllanguage/data/assignObjectToVariant.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/assignObjectToVariant.qml
diff --git a/tests/auto/declarative/qmllanguage/data/assignQmlComponent.qml b/tests/auto/declarative/qdeclarativelanguage/data/assignQmlComponent.qml
index 20bdc55..20bdc55 100644
--- a/tests/auto/declarative/qmllanguage/data/assignQmlComponent.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/assignQmlComponent.qml
diff --git a/tests/auto/declarative/qmllanguage/data/assignSignal.qml b/tests/auto/declarative/qdeclarativelanguage/data/assignSignal.qml
index 2a48df8..2a48df8 100644
--- a/tests/auto/declarative/qmllanguage/data/assignSignal.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/assignSignal.qml
diff --git a/tests/auto/declarative/qmllanguage/data/assignTypeExtremes.qml b/tests/auto/declarative/qdeclarativelanguage/data/assignTypeExtremes.qml
index 60ede52..60ede52 100644
--- a/tests/auto/declarative/qmllanguage/data/assignTypeExtremes.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/assignTypeExtremes.qml
diff --git a/tests/auto/declarative/qmllanguage/data/attachedProperties.qml b/tests/auto/declarative/qdeclarativelanguage/data/attachedProperties.qml
index b46ec34..b46ec34 100644
--- a/tests/auto/declarative/qmllanguage/data/attachedProperties.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/attachedProperties.qml
diff --git a/tests/auto/declarative/qmllanguage/data/autoComponentCreation.qml b/tests/auto/declarative/qdeclarativelanguage/data/autoComponentCreation.qml
index 5d00144..5d00144 100644
--- a/tests/auto/declarative/qmllanguage/data/autoComponentCreation.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/autoComponentCreation.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/autoNotifyConnection.qml b/tests/auto/declarative/qdeclarativelanguage/data/autoNotifyConnection.qml
new file mode 100644
index 0000000..640fb54
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/autoNotifyConnection.qml
@@ -0,0 +1,6 @@
+import Test 1.0
+MyQmlObject {
+ property bool receivedNotify : false
+ onPropertyWithNotifyChanged: { receivedNotify = true; }
+}
+
diff --git a/tests/auto/declarative/qmllanguage/data/component.1.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/component.1.errors.txt
index 091aad6..091aad6 100644
--- a/tests/auto/declarative/qmllanguage/data/component.1.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/component.1.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/component.1.qml b/tests/auto/declarative/qdeclarativelanguage/data/component.1.qml
index 07e463a..07e463a 100644
--- a/tests/auto/declarative/qmllanguage/data/component.1.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/component.1.qml
diff --git a/tests/auto/declarative/qmllanguage/data/component.2.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/component.2.errors.txt
index 76e7656..76e7656 100644
--- a/tests/auto/declarative/qmllanguage/data/component.2.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/component.2.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/component.2.qml b/tests/auto/declarative/qdeclarativelanguage/data/component.2.qml
index 88e0f73..88e0f73 100644
--- a/tests/auto/declarative/qmllanguage/data/component.2.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/component.2.qml
diff --git a/tests/auto/declarative/qmllanguage/data/component.3.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/component.3.errors.txt
index 9a13142..9a13142 100644
--- a/tests/auto/declarative/qmllanguage/data/component.3.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/component.3.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/component.3.qml b/tests/auto/declarative/qdeclarativelanguage/data/component.3.qml
index 287a959..287a959 100644
--- a/tests/auto/declarative/qmllanguage/data/component.3.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/component.3.qml
diff --git a/tests/auto/declarative/qmllanguage/data/component.4.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/component.4.errors.txt
index 2ab18685..2ab18685 100644
--- a/tests/auto/declarative/qmllanguage/data/component.4.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/component.4.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/component.4.qml b/tests/auto/declarative/qdeclarativelanguage/data/component.4.qml
index ab1e29b..ab1e29b 100644
--- a/tests/auto/declarative/qmllanguage/data/component.4.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/component.4.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/component.5.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/component.5.errors.txt
new file mode 100644
index 0000000..e3c2df7
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/component.5.errors.txt
@@ -0,0 +1 @@
+4:5:Component elements may not contain properties other than id
diff --git a/tests/auto/declarative/qmllanguage/data/component.5.qml b/tests/auto/declarative/qdeclarativelanguage/data/component.5.qml
index 629e998..629e998 100644
--- a/tests/auto/declarative/qmllanguage/data/component.5.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/component.5.qml
diff --git a/tests/auto/declarative/qmllanguage/data/component.6.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/component.6.errors.txt
index 2b1c6ca..2b1c6ca 100644
--- a/tests/auto/declarative/qmllanguage/data/component.6.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/component.6.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/component.6.qml b/tests/auto/declarative/qdeclarativelanguage/data/component.6.qml
index 2303ebf..2303ebf 100644
--- a/tests/auto/declarative/qmllanguage/data/component.6.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/component.6.qml
diff --git a/tests/auto/declarative/qmllanguage/data/componentCompositeType.qml b/tests/auto/declarative/qdeclarativelanguage/data/componentCompositeType.qml
index 0a7249a..0a7249a 100644
--- a/tests/auto/declarative/qmllanguage/data/componentCompositeType.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/componentCompositeType.qml
diff --git a/tests/auto/declarative/qmllanguage/data/cppnamespace.2.qml b/tests/auto/declarative/qdeclarativelanguage/data/cppnamespace.2.qml
index e3b32ca..e3b32ca 100644
--- a/tests/auto/declarative/qmllanguage/data/cppnamespace.2.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/cppnamespace.2.qml
diff --git a/tests/auto/declarative/qmllanguage/data/cppnamespace.qml b/tests/auto/declarative/qdeclarativelanguage/data/cppnamespace.qml
index e1daf3b..e1daf3b 100644
--- a/tests/auto/declarative/qmllanguage/data/cppnamespace.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/cppnamespace.qml
diff --git a/tests/auto/declarative/qmllanguage/data/crash2.qml b/tests/auto/declarative/qdeclarativelanguage/data/crash2.qml
index a22c776..a22c776 100644
--- a/tests/auto/declarative/qmllanguage/data/crash2.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/crash2.qml
diff --git a/tests/auto/declarative/qmllanguage/data/customParserIdNotAllowed.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/customParserIdNotAllowed.errors.txt
index 43a8bb2..43a8bb2 100644
--- a/tests/auto/declarative/qmllanguage/data/customParserIdNotAllowed.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/customParserIdNotAllowed.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/customParserIdNotAllowed.qml b/tests/auto/declarative/qdeclarativelanguage/data/customParserIdNotAllowed.qml
index 00cc0c4..00cc0c4 100644
--- a/tests/auto/declarative/qmllanguage/data/customParserIdNotAllowed.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/customParserIdNotAllowed.qml
diff --git a/tests/auto/declarative/qmllanguage/data/customParserTypes.qml b/tests/auto/declarative/qdeclarativelanguage/data/customParserTypes.qml
index cf2f272..cf2f272 100644
--- a/tests/auto/declarative/qmllanguage/data/customParserTypes.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/customParserTypes.qml
diff --git a/tests/auto/declarative/qmllanguage/data/customVariantTypes.qml b/tests/auto/declarative/qdeclarativelanguage/data/customVariantTypes.qml
index 0263ed2..0263ed2 100644
--- a/tests/auto/declarative/qmllanguage/data/customVariantTypes.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/customVariantTypes.qml
diff --git a/tests/auto/declarative/qmllanguage/data/declaredPropertyValues.qml b/tests/auto/declarative/qdeclarativelanguage/data/declaredPropertyValues.qml
index 3987a3c..3987a3c 100644
--- a/tests/auto/declarative/qmllanguage/data/declaredPropertyValues.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/declaredPropertyValues.qml
diff --git a/tests/auto/declarative/qmllanguage/data/defaultGrouped.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/defaultGrouped.errors.txt
index 945d51b..945d51b 100644
--- a/tests/auto/declarative/qmllanguage/data/defaultGrouped.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/defaultGrouped.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/defaultGrouped.qml b/tests/auto/declarative/qdeclarativelanguage/data/defaultGrouped.qml
index 0fd1404..0fd1404 100644
--- a/tests/auto/declarative/qmllanguage/data/defaultGrouped.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/defaultGrouped.qml
diff --git a/tests/auto/declarative/qmllanguage/data/defaultPropertyListOrder.qml b/tests/auto/declarative/qdeclarativelanguage/data/defaultPropertyListOrder.qml
index 3651511..3651511 100644
--- a/tests/auto/declarative/qmllanguage/data/defaultPropertyListOrder.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/defaultPropertyListOrder.qml
diff --git a/tests/auto/declarative/qmllanguage/data/doubleSignal.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/doubleSignal.errors.txt
index 2aea251..2aea251 100644
--- a/tests/auto/declarative/qmllanguage/data/doubleSignal.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/doubleSignal.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/doubleSignal.qml b/tests/auto/declarative/qdeclarativelanguage/data/doubleSignal.qml
index fb07b9f..fb07b9f 100644
--- a/tests/auto/declarative/qmllanguage/data/doubleSignal.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/doubleSignal.qml
diff --git a/tests/auto/declarative/qmllanguage/data/duplicateIDs.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/duplicateIDs.errors.txt
index 66241cf..66241cf 100644
--- a/tests/auto/declarative/qmllanguage/data/duplicateIDs.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/duplicateIDs.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/duplicateIDs.qml b/tests/auto/declarative/qdeclarativelanguage/data/duplicateIDs.qml
index a993abd..a993abd 100644
--- a/tests/auto/declarative/qmllanguage/data/duplicateIDs.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/duplicateIDs.qml
diff --git a/tests/auto/declarative/qmllanguage/data/dynamicObject.1.qml b/tests/auto/declarative/qdeclarativelanguage/data/dynamicObject.1.qml
index 85d1052..85d1052 100644
--- a/tests/auto/declarative/qmllanguage/data/dynamicObject.1.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/dynamicObject.1.qml
diff --git a/tests/auto/declarative/qmllanguage/data/dynamicObjectProperties.qml b/tests/auto/declarative/qdeclarativelanguage/data/dynamicObjectProperties.qml
index c80a7c0..c80a7c0 100644
--- a/tests/auto/declarative/qmllanguage/data/dynamicObjectProperties.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/dynamicObjectProperties.qml
diff --git a/tests/auto/declarative/qmllanguage/data/dynamicProperties.qml b/tests/auto/declarative/qdeclarativelanguage/data/dynamicProperties.qml
index aef3269..aef3269 100644
--- a/tests/auto/declarative/qmllanguage/data/dynamicProperties.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/dynamicProperties.qml
diff --git a/tests/auto/declarative/qmllanguage/data/dynamicPropertiesNested.qml b/tests/auto/declarative/qdeclarativelanguage/data/dynamicPropertiesNested.qml
index 7bfab67..7bfab67 100644
--- a/tests/auto/declarative/qmllanguage/data/dynamicPropertiesNested.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/dynamicPropertiesNested.qml
diff --git a/tests/auto/declarative/qmllanguage/data/dynamicSignalsAndSlots.qml b/tests/auto/declarative/qdeclarativelanguage/data/dynamicSignalsAndSlots.qml
index 2a834e8..2a834e8 100644
--- a/tests/auto/declarative/qmllanguage/data/dynamicSignalsAndSlots.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/dynamicSignalsAndSlots.qml
diff --git a/tests/auto/declarative/qmllanguage/data/empty.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/empty.errors.txt
index d416e76..d416e76 100644
--- a/tests/auto/declarative/qmllanguage/data/empty.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/empty.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/empty.qml b/tests/auto/declarative/qdeclarativelanguage/data/empty.qml
index e69de29..e69de29 100644
--- a/tests/auto/declarative/qmllanguage/data/empty.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/empty.qml
diff --git a/tests/auto/declarative/qmllanguage/data/emptySignal.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/emptySignal.errors.txt
index 353bbf5..353bbf5 100644
--- a/tests/auto/declarative/qmllanguage/data/emptySignal.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/emptySignal.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/emptySignal.qml b/tests/auto/declarative/qdeclarativelanguage/data/emptySignal.qml
index 4c5a122..4c5a122 100644
--- a/tests/auto/declarative/qmllanguage/data/emptySignal.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/emptySignal.qml
diff --git a/tests/auto/declarative/qmllanguage/data/failingComponent.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/failingComponent.errors.txt
index 0cf0ef3..0cf0ef3 100644
--- a/tests/auto/declarative/qmllanguage/data/failingComponent.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/failingComponent.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/failingComponentTest.qml b/tests/auto/declarative/qdeclarativelanguage/data/failingComponentTest.qml
index 74a6acf..74a6acf 100644
--- a/tests/auto/declarative/qmllanguage/data/failingComponentTest.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/failingComponentTest.qml
diff --git a/tests/auto/declarative/qmllanguage/data/fakeDotProperty.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/fakeDotProperty.errors.txt
index 3074823..3074823 100644
--- a/tests/auto/declarative/qmllanguage/data/fakeDotProperty.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/fakeDotProperty.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/fakeDotProperty.qml b/tests/auto/declarative/qdeclarativelanguage/data/fakeDotProperty.qml
index d971eee..d971eee 100644
--- a/tests/auto/declarative/qmllanguage/data/fakeDotProperty.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/fakeDotProperty.qml
diff --git a/tests/auto/declarative/qmllanguage/data/finalOverride.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/finalOverride.errors.txt
index 49e06cb..49e06cb 100644
--- a/tests/auto/declarative/qmllanguage/data/finalOverride.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/finalOverride.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/finalOverride.qml b/tests/auto/declarative/qdeclarativelanguage/data/finalOverride.qml
index a84393a..a84393a 100644
--- a/tests/auto/declarative/qmllanguage/data/finalOverride.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/finalOverride.qml
diff --git a/tests/auto/declarative/qmllanguage/data/i18nDeclaredPropertyNames.qml b/tests/auto/declarative/qdeclarativelanguage/data/i18nDeclaredPropertyNames.qml
index 558c836..558c836 100644
--- a/tests/auto/declarative/qmllanguage/data/i18nDeclaredPropertyNames.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/i18nDeclaredPropertyNames.qml
diff --git a/tests/auto/declarative/qmllanguage/data/i18nDeclaredPropertyUse.qml b/tests/auto/declarative/qdeclarativelanguage/data/i18nDeclaredPropertyUse.qml
index 74918e2..74918e2 100644
--- a/tests/auto/declarative/qmllanguage/data/i18nDeclaredPropertyUse.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/i18nDeclaredPropertyUse.qml
diff --git a/tests/auto/declarative/qmllanguage/data/i18nNameSpace.qml b/tests/auto/declarative/qdeclarativelanguage/data/i18nNameSpace.qml
index c0b2f94..c0b2f94 100644
--- a/tests/auto/declarative/qmllanguage/data/i18nNameSpace.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/i18nNameSpace.qml
diff --git a/tests/auto/declarative/qmllanguage/data/i18nScript.qml b/tests/auto/declarative/qdeclarativelanguage/data/i18nScript.qml
index 942ed90..942ed90 100644
--- a/tests/auto/declarative/qmllanguage/data/i18nScript.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/i18nScript.qml
diff --git a/tests/auto/declarative/qmllanguage/data/i18nStrings.qml b/tests/auto/declarative/qdeclarativelanguage/data/i18nStrings.qml
index 764c926..764c926 100644
--- a/tests/auto/declarative/qmllanguage/data/i18nStrings.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/i18nStrings.qml
diff --git a/tests/auto/declarative/qmllanguage/data/i18nType.qml b/tests/auto/declarative/qdeclarativelanguage/data/i18nType.qml
index d7954ef..d7954ef 100644
--- a/tests/auto/declarative/qmllanguage/data/i18nType.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/i18nType.qml
diff --git a/tests/auto/declarative/qmllanguage/data/idProperty.qml b/tests/auto/declarative/qdeclarativelanguage/data/idProperty.qml
index 90c1483..90c1483 100644
--- a/tests/auto/declarative/qmllanguage/data/idProperty.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/idProperty.qml
diff --git a/tests/auto/declarative/qmllanguage/data/importNamespaceConflict.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/importNamespaceConflict.errors.txt
index 231998d..231998d 100644
--- a/tests/auto/declarative/qmllanguage/data/importNamespaceConflict.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/importNamespaceConflict.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/importNamespaceConflict.qml b/tests/auto/declarative/qdeclarativelanguage/data/importNamespaceConflict.qml
index cd112af..cd112af 100644
--- a/tests/auto/declarative/qmllanguage/data/importNamespaceConflict.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/importNamespaceConflict.qml
diff --git a/tests/auto/declarative/qmllanguage/data/importVersionMissingBuiltIn.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/importVersionMissingBuiltIn.errors.txt
index c7d880e..c7d880e 100644
--- a/tests/auto/declarative/qmllanguage/data/importVersionMissingBuiltIn.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/importVersionMissingBuiltIn.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/importVersionMissingBuiltIn.qml b/tests/auto/declarative/qdeclarativelanguage/data/importVersionMissingBuiltIn.qml
index 23ed566..23ed566 100644
--- a/tests/auto/declarative/qmllanguage/data/importVersionMissingBuiltIn.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/importVersionMissingBuiltIn.qml
diff --git a/tests/auto/declarative/qmllanguage/data/importVersionMissingInstalled.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/importVersionMissingInstalled.errors.txt
index 89e58ee..89e58ee 100644
--- a/tests/auto/declarative/qmllanguage/data/importVersionMissingInstalled.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/importVersionMissingInstalled.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/importVersionMissingInstalled.qml b/tests/auto/declarative/qdeclarativelanguage/data/importVersionMissingInstalled.qml
index 97ec222..97ec222 100644
--- a/tests/auto/declarative/qmllanguage/data/importVersionMissingInstalled.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/importVersionMissingInstalled.qml
diff --git a/tests/auto/declarative/qmllanguage/data/inlineQmlComponents.qml b/tests/auto/declarative/qdeclarativelanguage/data/inlineQmlComponents.qml
index 478f06a..478f06a 100644
--- a/tests/auto/declarative/qmllanguage/data/inlineQmlComponents.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/inlineQmlComponents.qml
diff --git a/tests/auto/declarative/qmllanguage/data/interfaceProperty.qml b/tests/auto/declarative/qdeclarativelanguage/data/interfaceProperty.qml
index 70879ff..70879ff 100644
--- a/tests/auto/declarative/qmllanguage/data/interfaceProperty.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/interfaceProperty.qml
diff --git a/tests/auto/declarative/qmllanguage/data/interfaceQList.qml b/tests/auto/declarative/qdeclarativelanguage/data/interfaceQList.qml
index c87dfae..c87dfae 100644
--- a/tests/auto/declarative/qmllanguage/data/interfaceQList.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/interfaceQList.qml
diff --git a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.1.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.1.errors.txt
index 492bbb4..492bbb4 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.1.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.1.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.1.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.1.qml
index 324f79c..324f79c 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.1.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.1.qml
diff --git a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.10.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.10.errors.txt
index ff2409b..ff2409b 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.10.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.10.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.10.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.10.qml
index b768e9f..b768e9f 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.10.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.10.qml
diff --git a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.11.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.11.errors.txt
index fee5050..fee5050 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.11.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.11.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.11.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.11.qml
index 7b782be..7b782be 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.11.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.11.qml
diff --git a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.2.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.2.errors.txt
index 34de769..34de769 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.2.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.2.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.2.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.2.qml
index 1f47c61..1f47c61 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.2.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.2.qml
diff --git a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.3.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.3.errors.txt
index 05161c4..05161c4 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.3.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.3.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.3.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.3.qml
index 79c2981..79c2981 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.3.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.3.qml
diff --git a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.4.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.4.errors.txt
index a208bcf..a208bcf 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.4.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.4.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.4.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.4.qml
index af0be80..af0be80 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.4.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.4.qml
diff --git a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.5.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.5.errors.txt
index 05161c4..05161c4 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.5.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.5.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.5.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.5.qml
index 0546322..0546322 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.5.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.5.qml
diff --git a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.6.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.6.errors.txt
index 6770e1f..6770e1f 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.6.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.6.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.6.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.6.qml
index 108109a..108109a 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.6.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.6.qml
diff --git a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.7.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.7.errors.txt
index 6770e1f..6770e1f 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.7.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.7.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.7.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.7.qml
index ccf0353..ccf0353 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.7.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.7.qml
diff --git a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.8.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.8.errors.txt
index ff2409b..ff2409b 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.8.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.8.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.8.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.8.qml
index e736379..e736379 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.8.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.8.qml
diff --git a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.9.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.9.errors.txt
index 6770e1f..6770e1f 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.9.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.9.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.9.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.9.qml
index a095229..a095229 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.9.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.9.qml
diff --git a/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.1.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.1.errors.txt
index 810fd31..810fd31 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.1.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.1.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.1.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.1.qml
index 1167e39..1167e39 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.1.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.1.qml
diff --git a/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.2.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.2.errors.txt
index 810fd31..810fd31 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.2.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.2.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.2.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.2.qml
index a0c8306..a0c8306 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.2.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.2.qml
diff --git a/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.3.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.3.errors.txt
index f6d6f29..f6d6f29 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.3.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.3.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.3.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.3.qml
index 0bbfc4f..0bbfc4f 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.3.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.3.qml
diff --git a/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.4.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.4.errors.txt
index 69c6871..69c6871 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.4.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.4.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.4.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.4.qml
index 134fef9..134fef9 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.4.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.4.qml
diff --git a/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.5.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.5.errors.txt
index 2c8a970..2c8a970 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.5.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.5.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.5.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.5.qml
index 55cefe6..55cefe6 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.5.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.5.qml
diff --git a/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.6.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.6.errors.txt
index 8331725..8331725 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.6.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.6.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.6.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.6.qml
index 9ec33ab..9ec33ab 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.6.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.6.qml
diff --git a/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.7.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.7.errors.txt
index 4a7e383..4a7e383 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.7.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.7.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.7.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.7.qml
index 977539a..977539a 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.7.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.7.qml
diff --git a/tests/auto/declarative/qmllanguage/data/invalidID.2.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.2.errors.txt
index 56e3eeb..56e3eeb 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidID.2.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.2.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/invalidID.2.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.2.qml
index 4fb3b29..4fb3b29 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidID.2.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.2.qml
diff --git a/tests/auto/declarative/qmllanguage/data/invalidID.3.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.3.errors.txt
index bb811cf..bb811cf 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidID.3.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.3.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/invalidID.3.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.3.qml
index 6684172..6684172 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidID.3.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.3.qml
diff --git a/tests/auto/declarative/qmllanguage/data/invalidID.4.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.4.errors.txt
index cfe8756..cfe8756 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidID.4.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.4.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/invalidID.4.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.4.qml
index 86010bf..86010bf 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidID.4.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.4.qml
diff --git a/tests/auto/declarative/qmllanguage/data/invalidID.5.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.5.errors.txt
index c167de3..c167de3 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidID.5.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.5.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/invalidID.5.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.5.qml
index 5b92a1a..5b92a1a 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidID.5.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.5.qml
diff --git a/tests/auto/declarative/qmllanguage/data/invalidID.6.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.6.errors.txt
index 160e8b5..160e8b5 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidID.6.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.6.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/invalidID.6.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.6.qml
index 62187d9..62187d9 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidID.6.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.6.qml
diff --git a/tests/auto/declarative/qmllanguage/data/invalidID.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.errors.txt
index 1ca678c..1ca678c 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidID.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/invalidID.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.qml
index 04db3eb..04db3eb 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidID.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.qml
diff --git a/tests/auto/declarative/qmllanguage/data/invalidImportID.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/invalidImportID.errors.txt
index a65f5fd..a65f5fd 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidImportID.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidImportID.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/invalidImportID.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidImportID.qml
index 30d88d5..30d88d5 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidImportID.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidImportID.qml
diff --git a/tests/auto/declarative/qmllanguage/data/invalidRoot.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/invalidRoot.errors.txt
index 4bcc948..4bcc948 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidRoot.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidRoot.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/invalidRoot.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidRoot.qml
index 427827c..427827c 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidRoot.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidRoot.qml
diff --git a/tests/auto/declarative/qmllanguage/data/lib/com/nokia/installedtest/InstalledTest.qml b/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/InstalledTest.qml
index d8a22a8..d8a22a8 100644
--- a/tests/auto/declarative/qmllanguage/data/lib/com/nokia/installedtest/InstalledTest.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/InstalledTest.qml
diff --git a/tests/auto/declarative/qmllanguage/data/lib/com/nokia/installedtest/InstalledTest2.qml b/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/InstalledTest2.qml
index a0706ad..a0706ad 100644
--- a/tests/auto/declarative/qmllanguage/data/lib/com/nokia/installedtest/InstalledTest2.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/InstalledTest2.qml
diff --git a/tests/auto/declarative/qmllanguage/data/lib/com/nokia/installedtest/PrivateType.qml b/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/PrivateType.qml
index 93c7630..93c7630 100644
--- a/tests/auto/declarative/qmllanguage/data/lib/com/nokia/installedtest/PrivateType.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/PrivateType.qml
diff --git a/tests/auto/declarative/qmllanguage/data/lib/com/nokia/installedtest/qmldir b/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/qmldir
index eeb9a05..eeb9a05 100644
--- a/tests/auto/declarative/qmllanguage/data/lib/com/nokia/installedtest/qmldir
+++ b/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/qmldir
diff --git a/tests/auto/declarative/qmllanguage/data/listAssignment.2.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/listAssignment.2.errors.txt
index 8b40aa3..8b40aa3 100644
--- a/tests/auto/declarative/qmllanguage/data/listAssignment.2.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/listAssignment.2.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/listAssignment.2.qml b/tests/auto/declarative/qdeclarativelanguage/data/listAssignment.2.qml
index e3baadb..e3baadb 100644
--- a/tests/auto/declarative/qmllanguage/data/listAssignment.2.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/listAssignment.2.qml
diff --git a/tests/auto/declarative/qmllanguage/data/listAssignment.3.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/listAssignment.3.errors.txt
index 8c7b7e9..8c7b7e9 100644
--- a/tests/auto/declarative/qmllanguage/data/listAssignment.3.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/listAssignment.3.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/listAssignment.3.qml b/tests/auto/declarative/qdeclarativelanguage/data/listAssignment.3.qml
index 00c4c6b..00c4c6b 100644
--- a/tests/auto/declarative/qmllanguage/data/listAssignment.3.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/listAssignment.3.qml
diff --git a/tests/auto/declarative/qmllanguage/data/listItemDeleteSelf.qml b/tests/auto/declarative/qdeclarativelanguage/data/listItemDeleteSelf.qml
index 32b5b6c..32b5b6c 100644
--- a/tests/auto/declarative/qmllanguage/data/listItemDeleteSelf.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/listItemDeleteSelf.qml
diff --git a/tests/auto/declarative/qmllanguage/data/listProperties.qml b/tests/auto/declarative/qdeclarativelanguage/data/listProperties.qml
index ba9e37c..ba9e37c 100644
--- a/tests/auto/declarative/qmllanguage/data/listProperties.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/listProperties.qml
diff --git a/tests/auto/declarative/qmllanguage/data/missingObject.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/missingObject.errors.txt
index b31b562..b31b562 100644
--- a/tests/auto/declarative/qmllanguage/data/missingObject.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/missingObject.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/missingObject.qml b/tests/auto/declarative/qdeclarativelanguage/data/missingObject.qml
index 2f17045..2f17045 100644
--- a/tests/auto/declarative/qmllanguage/data/missingObject.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/missingObject.qml
diff --git a/tests/auto/declarative/qmllanguage/data/missingSignal.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/missingSignal.errors.txt
index f562246..f562246 100644
--- a/tests/auto/declarative/qmllanguage/data/missingSignal.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/missingSignal.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/missingSignal.qml b/tests/auto/declarative/qdeclarativelanguage/data/missingSignal.qml
index 3bf75f6..3bf75f6 100644
--- a/tests/auto/declarative/qmllanguage/data/missingSignal.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/missingSignal.qml
diff --git a/tests/auto/declarative/qmllanguage/data/missingValueTypeProperty.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/missingValueTypeProperty.errors.txt
index caf7e55..caf7e55 100644
--- a/tests/auto/declarative/qmllanguage/data/missingValueTypeProperty.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/missingValueTypeProperty.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/missingValueTypeProperty.qml b/tests/auto/declarative/qdeclarativelanguage/data/missingValueTypeProperty.qml
index 9a0fa6a..9a0fa6a 100644
--- a/tests/auto/declarative/qmllanguage/data/missingValueTypeProperty.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/missingValueTypeProperty.qml
diff --git a/tests/auto/declarative/qmllanguage/data/nestedErrors.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/nestedErrors.errors.txt
index 886da55..886da55 100644
--- a/tests/auto/declarative/qmllanguage/data/nestedErrors.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/nestedErrors.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/nestedErrors.qml b/tests/auto/declarative/qdeclarativelanguage/data/nestedErrors.qml
index c0d755a..c0d755a 100644
--- a/tests/auto/declarative/qmllanguage/data/nestedErrors.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/nestedErrors.qml
diff --git a/tests/auto/declarative/qmllanguage/data/nonexistantProperty.1.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.1.errors.txt
index 6bfce9a..6bfce9a 100644
--- a/tests/auto/declarative/qmllanguage/data/nonexistantProperty.1.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.1.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/nonexistantProperty.1.qml b/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.1.qml
index df7406c..df7406c 100644
--- a/tests/auto/declarative/qmllanguage/data/nonexistantProperty.1.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.1.qml
diff --git a/tests/auto/declarative/qmllanguage/data/nonexistantProperty.2.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.2.errors.txt
index 4b30056..4b30056 100644
--- a/tests/auto/declarative/qmllanguage/data/nonexistantProperty.2.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.2.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/nonexistantProperty.2.qml b/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.2.qml
index 06ccd37..06ccd37 100644
--- a/tests/auto/declarative/qmllanguage/data/nonexistantProperty.2.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.2.qml
diff --git a/tests/auto/declarative/qmllanguage/data/nonexistantProperty.3.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.3.errors.txt
index 4b30056..4b30056 100644
--- a/tests/auto/declarative/qmllanguage/data/nonexistantProperty.3.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.3.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/nonexistantProperty.3.qml b/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.3.qml
index 5b08608..5b08608 100644
--- a/tests/auto/declarative/qmllanguage/data/nonexistantProperty.3.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.3.qml
diff --git a/tests/auto/declarative/qmllanguage/data/nonexistantProperty.4.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.4.errors.txt
index 4b30056..4b30056 100644
--- a/tests/auto/declarative/qmllanguage/data/nonexistantProperty.4.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.4.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/nonexistantProperty.4.qml b/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.4.qml
index 6579191..6579191 100644
--- a/tests/auto/declarative/qmllanguage/data/nonexistantProperty.4.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.4.qml
diff --git a/tests/auto/declarative/qmllanguage/data/nonexistantProperty.5.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.5.errors.txt
index c07f2b9..c07f2b9 100644
--- a/tests/auto/declarative/qmllanguage/data/nonexistantProperty.5.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.5.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/nonexistantProperty.5.qml b/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.5.qml
index 37af057..37af057 100644
--- a/tests/auto/declarative/qmllanguage/data/nonexistantProperty.5.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.5.qml
diff --git a/tests/auto/declarative/qmllanguage/data/nonexistantProperty.6.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.6.errors.txt
index 89925b7..89925b7 100644
--- a/tests/auto/declarative/qmllanguage/data/nonexistantProperty.6.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.6.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/nonexistantProperty.6.qml b/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.6.qml
index 5cd55d0..5cd55d0 100644
--- a/tests/auto/declarative/qmllanguage/data/nonexistantProperty.6.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.6.qml
diff --git a/tests/auto/declarative/qmllanguage/data/nullDotProperty.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/nullDotProperty.errors.txt
index 07a4094..07a4094 100644
--- a/tests/auto/declarative/qmllanguage/data/nullDotProperty.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/nullDotProperty.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/nullDotProperty.qml b/tests/auto/declarative/qdeclarativelanguage/data/nullDotProperty.qml
index 4e36779..4e36779 100644
--- a/tests/auto/declarative/qmllanguage/data/nullDotProperty.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/nullDotProperty.qml
diff --git a/tests/auto/declarative/qmllanguage/data/objectValueTypeProperty.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/objectValueTypeProperty.errors.txt
index db7d9c0..db7d9c0 100644
--- a/tests/auto/declarative/qmllanguage/data/objectValueTypeProperty.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/objectValueTypeProperty.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/objectValueTypeProperty.qml b/tests/auto/declarative/qdeclarativelanguage/data/objectValueTypeProperty.qml
index 9924773..9924773 100644
--- a/tests/auto/declarative/qmllanguage/data/objectValueTypeProperty.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/objectValueTypeProperty.qml
diff --git a/tests/auto/declarative/qmllanguage/data/onCompleted.qml b/tests/auto/declarative/qdeclarativelanguage/data/onCompleted.qml
index 5725f85..5725f85 100644
--- a/tests/auto/declarative/qmllanguage/data/onCompleted.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/onCompleted.qml
diff --git a/tests/auto/declarative/qmllanguage/data/property.1.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/property.1.errors.txt
index 3ae6c46..3ae6c46 100644
--- a/tests/auto/declarative/qmllanguage/data/property.1.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/property.1.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/property.1.qml b/tests/auto/declarative/qdeclarativelanguage/data/property.1.qml
index cadc39a..cadc39a 100644
--- a/tests/auto/declarative/qmllanguage/data/property.1.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/property.1.qml
diff --git a/tests/auto/declarative/qmllanguage/data/property.2.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/property.2.errors.txt
index a18e21a..a18e21a 100644
--- a/tests/auto/declarative/qmllanguage/data/property.2.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/property.2.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/property.2.qml b/tests/auto/declarative/qdeclarativelanguage/data/property.2.qml
index e810c6c..e810c6c 100644
--- a/tests/auto/declarative/qmllanguage/data/property.2.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/property.2.qml
diff --git a/tests/auto/declarative/qmllanguage/data/property.3.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/property.3.errors.txt
index 5e09a25..5e09a25 100644
--- a/tests/auto/declarative/qmllanguage/data/property.3.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/property.3.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/property.3.qml b/tests/auto/declarative/qdeclarativelanguage/data/property.3.qml
index 04147c2..04147c2 100644
--- a/tests/auto/declarative/qmllanguage/data/property.3.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/property.3.qml
diff --git a/tests/auto/declarative/qmllanguage/data/property.4.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/property.4.errors.txt
index b447186..b447186 100644
--- a/tests/auto/declarative/qmllanguage/data/property.4.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/property.4.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/property.4.qml b/tests/auto/declarative/qdeclarativelanguage/data/property.4.qml
index b2ec482..b2ec482 100644
--- a/tests/auto/declarative/qmllanguage/data/property.4.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/property.4.qml
diff --git a/tests/auto/declarative/qmllanguage/data/property.5.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/property.5.errors.txt
index 32a8dc1..32a8dc1 100644
--- a/tests/auto/declarative/qmllanguage/data/property.5.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/property.5.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/property.5.qml b/tests/auto/declarative/qdeclarativelanguage/data/property.5.qml
index 65fafbb..65fafbb 100644
--- a/tests/auto/declarative/qmllanguage/data/property.5.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/property.5.qml
diff --git a/tests/auto/declarative/qmllanguage/data/propertyValueSource.2.qml b/tests/auto/declarative/qdeclarativelanguage/data/propertyValueSource.2.qml
index 57a6070..57a6070 100644
--- a/tests/auto/declarative/qmllanguage/data/propertyValueSource.2.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/propertyValueSource.2.qml
diff --git a/tests/auto/declarative/qmllanguage/data/propertyValueSource.qml b/tests/auto/declarative/qdeclarativelanguage/data/propertyValueSource.qml
index ad71fcf..ad71fcf 100644
--- a/tests/auto/declarative/qmllanguage/data/propertyValueSource.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/propertyValueSource.qml
diff --git a/tests/auto/declarative/qmllanguage/data/qmlAttachedPropertiesObjectMethod.1.qml b/tests/auto/declarative/qdeclarativelanguage/data/qmlAttachedPropertiesObjectMethod.1.qml
index 429c327..429c327 100644
--- a/tests/auto/declarative/qmllanguage/data/qmlAttachedPropertiesObjectMethod.1.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/qmlAttachedPropertiesObjectMethod.1.qml
diff --git a/tests/auto/declarative/qmllanguage/data/qmlAttachedPropertiesObjectMethod.2.qml b/tests/auto/declarative/qdeclarativelanguage/data/qmlAttachedPropertiesObjectMethod.2.qml
index 0f57b61..0f57b61 100644
--- a/tests/auto/declarative/qmllanguage/data/qmlAttachedPropertiesObjectMethod.2.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/qmlAttachedPropertiesObjectMethod.2.qml
diff --git a/tests/auto/declarative/qmllanguage/data/readOnly.1.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/readOnly.1.errors.txt
index b8c3404..b8c3404 100644
--- a/tests/auto/declarative/qmllanguage/data/readOnly.1.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/readOnly.1.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/readOnly.1.qml b/tests/auto/declarative/qdeclarativelanguage/data/readOnly.1.qml
index 60757bd..60757bd 100644
--- a/tests/auto/declarative/qmllanguage/data/readOnly.1.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/readOnly.1.qml
diff --git a/tests/auto/declarative/qmllanguage/data/readOnly.2.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/readOnly.2.errors.txt
index d857a04..d857a04 100644
--- a/tests/auto/declarative/qmllanguage/data/readOnly.2.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/readOnly.2.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/readOnly.2.qml b/tests/auto/declarative/qdeclarativelanguage/data/readOnly.2.qml
index 8f1633c..8f1633c 100644
--- a/tests/auto/declarative/qmllanguage/data/readOnly.2.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/readOnly.2.qml
diff --git a/tests/auto/declarative/qmllanguage/data/readOnly.3.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/readOnly.3.errors.txt
index c7e9e1b..c7e9e1b 100644
--- a/tests/auto/declarative/qmllanguage/data/readOnly.3.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/readOnly.3.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/readOnly.3.qml b/tests/auto/declarative/qdeclarativelanguage/data/readOnly.3.qml
index cd86a48..cd86a48 100644
--- a/tests/auto/declarative/qmllanguage/data/readOnly.3.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/readOnly.3.qml
diff --git a/tests/auto/declarative/qmllanguage/data/rootAsQmlComponent.qml b/tests/auto/declarative/qdeclarativelanguage/data/rootAsQmlComponent.qml
index 8d72cd3..8d72cd3 100644
--- a/tests/auto/declarative/qmllanguage/data/rootAsQmlComponent.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/rootAsQmlComponent.qml
diff --git a/tests/auto/declarative/qmllanguage/data/script.1.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/script.1.errors.txt
index 50518cc..50518cc 100644
--- a/tests/auto/declarative/qmllanguage/data/script.1.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/script.1.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/script.1.qml b/tests/auto/declarative/qdeclarativelanguage/data/script.1.qml
index 8dac8b7..8dac8b7 100644
--- a/tests/auto/declarative/qmllanguage/data/script.1.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/script.1.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/script.10.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/script.10.errors.txt
new file mode 100644
index 0000000..13f47d1
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/script.10.errors.txt
@@ -0,0 +1 @@
+6:9:Component elements may not contain script blocks
diff --git a/tests/auto/declarative/qmllanguage/data/script.10.qml b/tests/auto/declarative/qdeclarativelanguage/data/script.10.qml
index 516e878..516e878 100644
--- a/tests/auto/declarative/qmllanguage/data/script.10.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/script.10.qml
diff --git a/tests/auto/declarative/qmllanguage/data/script.11.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/script.11.errors.txt
index a664203..a664203 100644
--- a/tests/auto/declarative/qmllanguage/data/script.11.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/script.11.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/script.11.qml b/tests/auto/declarative/qdeclarativelanguage/data/script.11.qml
index 6d2d598..6d2d598 100644
--- a/tests/auto/declarative/qmllanguage/data/script.11.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/script.11.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/script.12.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/script.12.errors.txt
new file mode 100644
index 0000000..f8297f5
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/script.12.errors.txt
@@ -0,0 +1 @@
+4:5:JavaScript declaration outside Script element
diff --git a/tests/auto/declarative/qmllanguage/data/script.12.qml b/tests/auto/declarative/qdeclarativelanguage/data/script.12.qml
index 9ecb5d9..9ecb5d9 100644
--- a/tests/auto/declarative/qmllanguage/data/script.12.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/script.12.qml
diff --git a/tests/auto/declarative/qmllanguage/data/script.2.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/script.2.errors.txt
index 8fb3bbd..8fb3bbd 100644
--- a/tests/auto/declarative/qmllanguage/data/script.2.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/script.2.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/script.2.qml b/tests/auto/declarative/qdeclarativelanguage/data/script.2.qml
index dce1a41..dce1a41 100644
--- a/tests/auto/declarative/qmllanguage/data/script.2.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/script.2.qml
diff --git a/tests/auto/declarative/qmllanguage/data/script.3.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/script.3.errors.txt
index 8fb3bbd..8fb3bbd 100644
--- a/tests/auto/declarative/qmllanguage/data/script.3.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/script.3.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/script.3.qml b/tests/auto/declarative/qdeclarativelanguage/data/script.3.qml
index 8621a9a..8621a9a 100644
--- a/tests/auto/declarative/qmllanguage/data/script.3.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/script.3.qml
diff --git a/tests/auto/declarative/qmllanguage/data/script.4.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/script.4.errors.txt
index 49a507f..49a507f 100644
--- a/tests/auto/declarative/qmllanguage/data/script.4.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/script.4.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/script.4.qml b/tests/auto/declarative/qdeclarativelanguage/data/script.4.qml
index d89817c..d89817c 100644
--- a/tests/auto/declarative/qmllanguage/data/script.4.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/script.4.qml
diff --git a/tests/auto/declarative/qmllanguage/data/script.5.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/script.5.errors.txt
index 49a507f..49a507f 100644
--- a/tests/auto/declarative/qmllanguage/data/script.5.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/script.5.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/script.5.qml b/tests/auto/declarative/qdeclarativelanguage/data/script.5.qml
index 8986b3b..8986b3b 100644
--- a/tests/auto/declarative/qmllanguage/data/script.5.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/script.5.qml
diff --git a/tests/auto/declarative/qmllanguage/data/script.6.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/script.6.errors.txt
index 4e53b6b..4e53b6b 100644
--- a/tests/auto/declarative/qmllanguage/data/script.6.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/script.6.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/script.6.qml b/tests/auto/declarative/qdeclarativelanguage/data/script.6.qml
index 07e9d78..07e9d78 100644
--- a/tests/auto/declarative/qmllanguage/data/script.6.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/script.6.qml
diff --git a/tests/auto/declarative/qmllanguage/data/script.7.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/script.7.errors.txt
index dc15ddf..dc15ddf 100644
--- a/tests/auto/declarative/qmllanguage/data/script.7.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/script.7.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/script.7.qml b/tests/auto/declarative/qdeclarativelanguage/data/script.7.qml
index fa905e6..fa905e6 100644
--- a/tests/auto/declarative/qmllanguage/data/script.7.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/script.7.qml
diff --git a/tests/auto/declarative/qmllanguage/data/script.8.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/script.8.errors.txt
index b5bf1a8..b5bf1a8 100644
--- a/tests/auto/declarative/qmllanguage/data/script.8.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/script.8.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/script.8.qml b/tests/auto/declarative/qdeclarativelanguage/data/script.8.qml
index f600c88..f600c88 100644
--- a/tests/auto/declarative/qmllanguage/data/script.8.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/script.8.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/script.9.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/script.9.errors.txt
new file mode 100644
index 0000000..41e8d46
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/script.9.errors.txt
@@ -0,0 +1 @@
+5:9:Component elements may not contain script blocks
diff --git a/tests/auto/declarative/qmllanguage/data/script.9.qml b/tests/auto/declarative/qdeclarativelanguage/data/script.9.qml
index 79aa504..79aa504 100644
--- a/tests/auto/declarative/qmllanguage/data/script.9.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/script.9.qml
diff --git a/tests/auto/declarative/qmllanguage/data/scriptString.qml b/tests/auto/declarative/qdeclarativelanguage/data/scriptString.qml
index 40a3bbe..40a3bbe 100644
--- a/tests/auto/declarative/qmllanguage/data/scriptString.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/scriptString.qml
diff --git a/tests/auto/declarative/qmllanguage/data/signal.1.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/signal.1.errors.txt
index 78d9960..78d9960 100644
--- a/tests/auto/declarative/qmllanguage/data/signal.1.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/signal.1.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/signal.1.qml b/tests/auto/declarative/qdeclarativelanguage/data/signal.1.qml
index fbaf017..fbaf017 100644
--- a/tests/auto/declarative/qmllanguage/data/signal.1.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/signal.1.qml
diff --git a/tests/auto/declarative/qmllanguage/data/signal.2.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/signal.2.errors.txt
index fce8928..fce8928 100644
--- a/tests/auto/declarative/qmllanguage/data/signal.2.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/signal.2.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/signal.2.qml b/tests/auto/declarative/qdeclarativelanguage/data/signal.2.qml
index 5049192..5049192 100644
--- a/tests/auto/declarative/qmllanguage/data/signal.2.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/signal.2.qml
diff --git a/tests/auto/declarative/qmllanguage/data/signal.3.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/signal.3.errors.txt
index bf043ac..bf043ac 100644
--- a/tests/auto/declarative/qmllanguage/data/signal.3.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/signal.3.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/signal.3.qml b/tests/auto/declarative/qdeclarativelanguage/data/signal.3.qml
index 9dd4cc7..9dd4cc7 100644
--- a/tests/auto/declarative/qmllanguage/data/signal.3.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/signal.3.qml
diff --git a/tests/auto/declarative/qmllanguage/data/simpleBindings.qml b/tests/auto/declarative/qdeclarativelanguage/data/simpleBindings.qml
index 2fcd1a5..2fcd1a5 100644
--- a/tests/auto/declarative/qmllanguage/data/simpleBindings.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/simpleBindings.qml
diff --git a/tests/auto/declarative/qmllanguage/data/simpleContainer.qml b/tests/auto/declarative/qdeclarativelanguage/data/simpleContainer.qml
index c3a795f..c3a795f 100644
--- a/tests/auto/declarative/qmllanguage/data/simpleContainer.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/simpleContainer.qml
diff --git a/tests/auto/declarative/qmllanguage/data/simpleObject.qml b/tests/auto/declarative/qdeclarativelanguage/data/simpleObject.qml
index 30c7823..30c7823 100644
--- a/tests/auto/declarative/qmllanguage/data/simpleObject.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/simpleObject.qml
diff --git a/tests/auto/declarative/qmllanguage/qtest/declarative/qmllanguage/Test.qml b/tests/auto/declarative/qdeclarativelanguage/data/subdir/Test.qml
index c4d5905..c4d5905 100644
--- a/tests/auto/declarative/qmllanguage/qtest/declarative/qmllanguage/Test.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/subdir/Test.qml
diff --git a/tests/auto/declarative/qmllanguage/data/subdir/subsubdir/SubTest.qml b/tests/auto/declarative/qdeclarativelanguage/data/subdir/subsubdir/SubTest.qml
index c4d5905..c4d5905 100644
--- a/tests/auto/declarative/qmllanguage/data/subdir/subsubdir/SubTest.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/subdir/subsubdir/SubTest.qml
diff --git a/tests/auto/declarative/qmllanguage/data/test.js b/tests/auto/declarative/qdeclarativelanguage/data/test.js
index e69de29..e69de29 100644
--- a/tests/auto/declarative/qmllanguage/data/test.js
+++ b/tests/auto/declarative/qdeclarativelanguage/data/test.js
diff --git a/tests/auto/declarative/qmllanguage/data/test2.js b/tests/auto/declarative/qdeclarativelanguage/data/test2.js
index e69de29..e69de29 100644
--- a/tests/auto/declarative/qmllanguage/data/test2.js
+++ b/tests/auto/declarative/qdeclarativelanguage/data/test2.js
diff --git a/tests/auto/declarative/qmllanguage/data/unregisteredObject.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/unregisteredObject.errors.txt
index 347db05..347db05 100644
--- a/tests/auto/declarative/qmllanguage/data/unregisteredObject.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/unregisteredObject.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/unregisteredObject.qml b/tests/auto/declarative/qdeclarativelanguage/data/unregisteredObject.qml
index 4969f62..4969f62 100644
--- a/tests/auto/declarative/qmllanguage/data/unregisteredObject.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/unregisteredObject.qml
diff --git a/tests/auto/declarative/qmllanguage/data/unsupportedProperty.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/unsupportedProperty.errors.txt
index 3cd626d..3cd626d 100644
--- a/tests/auto/declarative/qmllanguage/data/unsupportedProperty.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/unsupportedProperty.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/unsupportedProperty.qml b/tests/auto/declarative/qdeclarativelanguage/data/unsupportedProperty.qml
index 9f19680..9f19680 100644
--- a/tests/auto/declarative/qmllanguage/data/unsupportedProperty.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/unsupportedProperty.qml
diff --git a/tests/auto/declarative/qmllanguage/data/valueTypes.qml b/tests/auto/declarative/qdeclarativelanguage/data/valueTypes.qml
index bf325a7..bf325a7 100644
--- a/tests/auto/declarative/qmllanguage/data/valueTypes.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/valueTypes.qml
diff --git a/tests/auto/declarative/qmllanguage/data/wrongType.1.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.1.errors.txt
index ba7a076..ba7a076 100644
--- a/tests/auto/declarative/qmllanguage/data/wrongType.1.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.1.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/wrongType.1.qml b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.1.qml
index 289d37f..289d37f 100644
--- a/tests/auto/declarative/qmllanguage/data/wrongType.1.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.1.qml
diff --git a/tests/auto/declarative/qmllanguage/data/wrongType.10.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.10.errors.txt
index ae75b52..ae75b52 100644
--- a/tests/auto/declarative/qmllanguage/data/wrongType.10.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.10.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/wrongType.10.qml b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.10.qml
index 2cf0e50..2cf0e50 100644
--- a/tests/auto/declarative/qmllanguage/data/wrongType.10.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.10.qml
diff --git a/tests/auto/declarative/qmllanguage/data/wrongType.11.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.11.errors.txt
index 23a4cda..23a4cda 100644
--- a/tests/auto/declarative/qmllanguage/data/wrongType.11.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.11.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/wrongType.11.qml b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.11.qml
index ae77ba1..ae77ba1 100644
--- a/tests/auto/declarative/qmllanguage/data/wrongType.11.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.11.qml
diff --git a/tests/auto/declarative/qmllanguage/data/wrongType.12.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.12.errors.txt
index 3092100..3092100 100644
--- a/tests/auto/declarative/qmllanguage/data/wrongType.12.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.12.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/wrongType.12.qml b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.12.qml
index b7a366f..b7a366f 100644
--- a/tests/auto/declarative/qmllanguage/data/wrongType.12.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.12.qml
diff --git a/tests/auto/declarative/qmllanguage/data/wrongType.13.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.13.errors.txt
index ba7a076..ba7a076 100644
--- a/tests/auto/declarative/qmllanguage/data/wrongType.13.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.13.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/wrongType.13.qml b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.13.qml
index 477aff1..477aff1 100644
--- a/tests/auto/declarative/qmllanguage/data/wrongType.13.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.13.qml
diff --git a/tests/auto/declarative/qmllanguage/data/wrongType.14.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.14.errors.txt
index d621fdd..d621fdd 100644
--- a/tests/auto/declarative/qmllanguage/data/wrongType.14.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.14.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/wrongType.14.qml b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.14.qml
index 672d693..672d693 100644
--- a/tests/auto/declarative/qmllanguage/data/wrongType.14.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.14.qml
diff --git a/tests/auto/declarative/qmllanguage/data/wrongType.15.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.15.errors.txt
index 44768e3..44768e3 100644
--- a/tests/auto/declarative/qmllanguage/data/wrongType.15.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.15.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/wrongType.15.qml b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.15.qml
index 633a5ba..633a5ba 100644
--- a/tests/auto/declarative/qmllanguage/data/wrongType.15.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.15.qml
diff --git a/tests/auto/declarative/qmllanguage/data/wrongType.2.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.2.errors.txt
index 9ff9f25..9ff9f25 100644
--- a/tests/auto/declarative/qmllanguage/data/wrongType.2.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.2.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/wrongType.2.qml b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.2.qml
index 34b74f7..34b74f7 100644
--- a/tests/auto/declarative/qmllanguage/data/wrongType.2.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.2.qml
diff --git a/tests/auto/declarative/qmllanguage/data/wrongType.3.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.3.errors.txt
index 6d971c6..6d971c6 100644
--- a/tests/auto/declarative/qmllanguage/data/wrongType.3.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.3.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/wrongType.3.qml b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.3.qml
index 384181a..384181a 100644
--- a/tests/auto/declarative/qmllanguage/data/wrongType.3.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.3.qml
diff --git a/tests/auto/declarative/qmllanguage/data/wrongType.4.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.4.errors.txt
index ef34d0e..ef34d0e 100644
--- a/tests/auto/declarative/qmllanguage/data/wrongType.4.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.4.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/wrongType.4.qml b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.4.qml
index 0787bf5..0787bf5 100644
--- a/tests/auto/declarative/qmllanguage/data/wrongType.4.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.4.qml
diff --git a/tests/auto/declarative/qmllanguage/data/wrongType.5.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.5.errors.txt
index cab10bd..cab10bd 100644
--- a/tests/auto/declarative/qmllanguage/data/wrongType.5.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.5.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/wrongType.5.qml b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.5.qml
index c50ae9a..c50ae9a 100644
--- a/tests/auto/declarative/qmllanguage/data/wrongType.5.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.5.qml
diff --git a/tests/auto/declarative/qmllanguage/data/wrongType.6.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.6.errors.txt
index d0a0b00..d0a0b00 100644
--- a/tests/auto/declarative/qmllanguage/data/wrongType.6.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.6.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/wrongType.6.qml b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.6.qml
index da10b78..da10b78 100644
--- a/tests/auto/declarative/qmllanguage/data/wrongType.6.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.6.qml
diff --git a/tests/auto/declarative/qmllanguage/data/wrongType.7.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.7.errors.txt
index 614346b..614346b 100644
--- a/tests/auto/declarative/qmllanguage/data/wrongType.7.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.7.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/wrongType.7.qml b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.7.qml
index ddc3835..ddc3835 100644
--- a/tests/auto/declarative/qmllanguage/data/wrongType.7.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.7.qml
diff --git a/tests/auto/declarative/qmllanguage/data/wrongType.8.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.8.errors.txt
index 1773c00..1773c00 100644
--- a/tests/auto/declarative/qmllanguage/data/wrongType.8.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.8.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/wrongType.8.qml b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.8.qml
index a5f6756..a5f6756 100644
--- a/tests/auto/declarative/qmllanguage/data/wrongType.8.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.8.qml
diff --git a/tests/auto/declarative/qmllanguage/data/wrongType.9.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.9.errors.txt
index 8630975..8630975 100644
--- a/tests/auto/declarative/qmllanguage/data/wrongType.9.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.9.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/wrongType.9.qml b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.9.qml
index a3db732..a3db732 100644
--- a/tests/auto/declarative/qmllanguage/data/wrongType.9.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.9.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/qdeclarativelanguage.pro b/tests/auto/declarative/qdeclarativelanguage/qdeclarativelanguage.pro
new file mode 100644
index 0000000..d7c1def
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/qdeclarativelanguage.pro
@@ -0,0 +1,14 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative
+QT += script network
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qdeclarativelanguage.cpp \
+ testtypes.cpp
+HEADERS += testtypes.h
+
+INCLUDEPATH += ../shared/
+HEADERS += ../shared/testhttpserver.h
+SOURCES += ../shared/testhttpserver.cpp
+
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmllanguage/qtest/declarative/qmllanguage/LocalInternal.qml b/tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/LocalInternal.qml
index 836c20a..836c20a 100644
--- a/tests/auto/declarative/qmllanguage/qtest/declarative/qmllanguage/LocalInternal.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/LocalInternal.qml
diff --git a/tests/auto/declarative/qmllanguage/data/subdir/Test.qml b/tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/Test.qml
index c4d5905..c4d5905 100644
--- a/tests/auto/declarative/qmllanguage/data/subdir/Test.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/Test.qml
diff --git a/tests/auto/declarative/qmllanguage/qtest/declarative/qmllanguage/TestLocal.qml b/tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/TestLocal.qml
index 11443ca..11443ca 100644
--- a/tests/auto/declarative/qmllanguage/qtest/declarative/qmllanguage/TestLocal.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/TestLocal.qml
diff --git a/tests/auto/declarative/qmllanguage/qtest/declarative/qmllanguage/TestSubDir.qml b/tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/TestSubDir.qml
index 0dfede4..0dfede4 100644
--- a/tests/auto/declarative/qmllanguage/qtest/declarative/qmllanguage/TestSubDir.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/TestSubDir.qml
diff --git a/tests/auto/declarative/qmllanguage/qtest/declarative/qmllanguage/pics/blue.png b/tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/pics/blue.png
index 46f815f..46f815f 100644
--- a/tests/auto/declarative/qmllanguage/qtest/declarative/qmllanguage/pics/blue.png
+++ b/tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/pics/blue.png
Binary files differ
diff --git a/tests/auto/declarative/qmllanguage/qtest/declarative/qmllanguage/qmldir b/tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/qmldir
index b32f82b..b32f82b 100644
--- a/tests/auto/declarative/qmllanguage/qtest/declarative/qmllanguage/qmldir
+++ b/tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/qmldir
diff --git a/tests/auto/declarative/qmllanguage/qtest/declarative/qmllanguage/subdir/SubTest.qml b/tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/subdir/SubTest.qml
index 0ea9ec6..0ea9ec6 100644
--- a/tests/auto/declarative/qmllanguage/qtest/declarative/qmllanguage/subdir/SubTest.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/subdir/SubTest.qml
diff --git a/tests/auto/declarative/qmllanguage/qtest/declarative/qmllanguage/subdir/qmldir b/tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/subdir/qmldir
index f7016c7..f7016c7 100644
--- a/tests/auto/declarative/qmllanguage/qtest/declarative/qmllanguage/subdir/qmldir
+++ b/tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/subdir/qmldir
diff --git a/tests/auto/declarative/qdeclarativelanguage/testtypes.cpp b/tests/auto/declarative/qdeclarativelanguage/testtypes.cpp
new file mode 100644
index 0000000..9ffe28a
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/testtypes.cpp
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "testtypes.h"
+
+void registerTypes()
+{
+ QML_REGISTER_INTERFACE(MyInterface);
+ QML_REGISTER_TYPE(Test,1,0,MyQmlObject,MyQmlObject);
+ QML_REGISTER_TYPE(Test,1,0,MyTypeObject,MyTypeObject);
+ QML_REGISTER_TYPE(Test,1,0,MyContainer,MyContainer);
+ QML_REGISTER_TYPE(Test,1,0,MyPropertyValueSource,MyPropertyValueSource);
+ QML_REGISTER_TYPE(Test,1,0,MyDotPropertyObject,MyDotPropertyObject);
+ QML_REGISTER_TYPE(Test,1,0,MyNamespacedType,MyNamespace::MyNamespacedType);
+ QML_REGISTER_TYPE(Test,1,0,MySecondNamespacedType,MyNamespace::MySecondNamespacedType);
+ QML_REGISTER_NOCREATE_TYPE(MyGroupedObject);
+}
+
+QVariant myCustomVariantTypeConverter(const QString &data)
+{
+ MyCustomVariantType rv;
+ rv.a = data.toInt();
+ return QVariant::fromValue(rv);
+}
+
diff --git a/tests/auto/declarative/qdeclarativelanguage/testtypes.h b/tests/auto/declarative/qdeclarativelanguage/testtypes.h
new file mode 100644
index 0000000..8ac7aa6
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/testtypes.h
@@ -0,0 +1,554 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef 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 <QtDeclarative/qdeclarative.h>
+#include <QtDeclarative/qdeclarativecomponent.h>
+#include <QtDeclarative/qdeclarativeparserstatus.h>
+#include <QtDeclarative/qdeclarativepropertyvaluesource.h>
+#include <QtDeclarative/qdeclarativescriptstring.h>
+#include <QtDeclarative/qdeclarativeproperty.h>
+
+QVariant myCustomVariantTypeConverter(const QString &data);
+
+class MyInterface
+{
+public:
+ MyInterface() : id(913) {}
+ int id;
+};
+Q_DECLARE_INTERFACE(MyInterface, "com.trolltech.Qt.Test.MyInterface");
+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)
+ 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) { m_value = v; }
+
+ int value2() const { return m_value2; }
+ void setValue2(int v) { m_value2 = v; }
+
+private:
+ int m_value;
+ int m_value2;
+};
+
+class MyQmlObject : public QObject, public MyInterface, public QDeclarativeParserStatus
+{
+ 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_INTERFACES(MyInterface QDeclarativeParserStatus)
+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(); }
+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_TYPEINFO(MyQmlObject, QML_HAS_ATTACHED_PROPERTIES)
+QML_DECLARE_TYPE(MyQmlObject);
+
+class MyGroupedObject : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QDeclarativeScriptString script READ script WRITE setScript);
+public:
+ QDeclarativeScriptString script() const { return m_script; }
+ void setScript(const QDeclarativeScriptString &s) { m_script = s; }
+
+private:
+ QDeclarativeScriptString m_script;
+};
+
+QML_DECLARE_TYPE(MyGroupedObject);
+
+
+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);
+ 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;
+ }
+
+ 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;
+ }
+
+ 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)
+QML_DECLARE_TYPE(MyTypeObject);
+
+class MyContainer : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QDeclarativeListProperty<QObject> children READ children)
+ Q_PROPERTY(QDeclarativeListProperty<MyInterface> qlistInterfaces READ qlistInterfaces)
+ Q_CLASSINFO("DefaultProperty", "children");
+public:
+ MyContainer() {}
+
+ QDeclarativeListProperty<QObject> children() { return QDeclarativeListProperty<QObject>(this, m_children); }
+ QList<QObject *> *getChildren() { return &m_children; }
+ QDeclarativeListProperty<MyInterface> qlistInterfaces() { return QDeclarativeListProperty<MyInterface>(this, m_interfaces); }
+ QList<MyInterface *> *getQListInterfaces() { return &m_interfaces; }
+
+ QList<QObject*> m_children;
+ QList<MyInterface *> m_interfaces;
+};
+
+QML_DECLARE_TYPE(MyContainer);
+
+
+class MyPropertyValueSource : public QObject, public QDeclarativePropertyValueSource
+{
+ Q_OBJECT
+ Q_INTERFACES(QDeclarativePropertyValueSource)
+public:
+ MyPropertyValueSource()
+ : QDeclarativePropertyValueSource() {}
+
+ QDeclarativeProperty prop;
+ virtual void setTarget(const QDeclarativeProperty &p)
+ {
+ prop = p;
+ }
+};
+QML_DECLARE_TYPE(MyPropertyValueSource);
+
+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;
+};
+
+QML_DECLARE_TYPE(MyDotPropertyObject);
+
+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;
+ };
+}
+QML_DECLARE_TYPE(MyNamespace::MyNamespacedType);
+QML_DECLARE_TYPE(MyNamespace::MySecondNamespacedType);
+
+void registerTypes();
+
+#endif // TESTTYPES_H
diff --git a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
new file mode 100644
index 0000000..1ba4454
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
@@ -0,0 +1,1406 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QtDeclarative/qdeclarativeengine.h>
+#include <QtDeclarative/qdeclarativecomponent.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 "testtypes.h"
+
+#include "../../../shared/util.h"
+
+/*
+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);
+ QFileInfo fileInfo(__FILE__);
+ engine.addImportPath(fileInfo.absoluteDir().filePath(QLatin1String("data/lib")));
+ }
+
+private slots:
+ void initTestCase();
+ void cleanupTestCase();
+
+ void errors_data();
+ void errors();
+
+ void simpleObject();
+ void simpleContainer();
+ void interfaceProperty();
+ void interfaceQList();
+ void assignObjectToSignal();
+ void assignObjectToVariant();
+ void assignLiteralSignalProperty();
+ void assignQmlComponent();
+ void assignBasicTypes();
+ void assignTypeExtremes();
+ void assignCompositeToType();
+ 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 componentCompositeType();
+ void i18n();
+ void i18n_data();
+ void onCompleted();
+ void scriptString();
+ void defaultPropertyListOrder();
+ void declaredPropertyValues();
+
+ 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 qmlAttachedPropertiesObjectMethod();
+
+ // regression tests for crashes
+ void crash1();
+ void crash2();
+
+private:
+ QDeclarativeEngine engine;
+ void testType(const QString& qml, const QString& type);
+};
+
+#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 { \
+ QFile file(QLatin1String(SRCDIR) + QLatin1String("/data/") + QLatin1String(errorfile)); \
+ QVERIFY(file.open(QIODevice::ReadOnly)); \
+ 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(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)
+{
+ QFileInfo fileInfo(__FILE__);
+ return QUrl::fromLocalFile(fileInfo.absoluteDir().filePath(QLatin1String("data/") + 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::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("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("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("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("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("invalidImportID") << "invalidImportID.qml" << "invalidImportID.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("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.5") << "property.5.qml" << "property.5.errors.txt" << false;
+
+ QTest::newRow("Script.1") << "script.1.qml" << "script.1.errors.txt" << false;
+ QTest::newRow("Script.2") << "script.2.qml" << "script.2.errors.txt" << false;
+ QTest::newRow("Script.3") << "script.3.qml" << "script.3.errors.txt" << false;
+ QTest::newRow("Script.4") << "script.4.qml" << "script.4.errors.txt" << false;
+ QTest::newRow("Script.5") << "script.5.qml" << "script.5.errors.txt" << false;
+ QTest::newRow("Script.6") << "script.6.qml" << "script.6.errors.txt" << false;
+ QTest::newRow("Script.7") << "script.7.qml" << "script.7.errors.txt" << false;
+ QTest::newRow("Script.8") << "script.8.qml" << "script.8.errors.txt" << false;
+ QTest::newRow("Script.9") << "script.9.qml" << "script.9.errors.txt" << false;
+ QTest::newRow("Script.10") << "script.10.qml" << "script.10.errors.txt" << false;
+ QTest::newRow("Script.11") << "script.11.qml" << "script.11.errors.txt" << false;
+ QTest::newRow("Script.12") << "script.12.qml" << "script.12.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("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("nestedErrors") << "nestedErrors.qml" << "nestedErrors.errors.txt" << false;
+ QTest::newRow("defaultGrouped") << "defaultGrouped.qml" << "defaultGrouped.errors.txt" << false;
+ QTest::newRow("emptySignal") << "emptySignal.qml" << "emptySignal.errors.txt" << false;
+ QTest::newRow("doubleSignal") << "doubleSignal.qml" << "doubleSignal.errors.txt" << false;
+ QTest::newRow("invalidRoot") << "invalidRoot.qml" << "invalidRoot.errors.txt" << false;
+ QTest::newRow("missingValueTypeProperty") << "missingValueTypeProperty.qml" << "missingValueTypeProperty.errors.txt" << false;
+ QTest::newRow("objectValueTypeProperty") << "objectValueTypeProperty.qml" << "objectValueTypeProperty.errors.txt" << false;
+}
+
+
+void tst_qdeclarativelanguage::errors()
+{
+ QFETCH(QString, file);
+ QFETCH(QString, errorFile);
+ QFETCH(bool, create);
+
+ if (file == "invalidID.6.qml")
+ QTest::ignoreMessage(QtWarningMsg, "id \"StartsWithUpperCase\" is invalid: ids cannot start with uppercase letters");
+
+ 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((float)-10.1, (float)12.3));
+ QCOMPARE(object->sizeProperty(), QSize(99, 13));
+ QCOMPARE(object->sizeFProperty(), QSizeF((float)0.1, (float)0.2));
+ QCOMPARE(object->rectProperty(), QRect(9, 7, 100, 200));
+ QCOMPARE(object->rectFProperty(), QRectF((float)1000.1, (float)-10.9, (float)400, (float)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")));
+ 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);
+}
+
+// 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!"));
+ QCOMPARE(object->property("variantProperty"), QVariant(12));
+}
+
+// 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));
+}
+
+// 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(), 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(), 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 = QLatin1String("QML MyTypeObject (") + component.url().toString() +
+ QLatin1String(":2:1) 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 throught 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;
+ }
+}
+
+// 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 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(), 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(), object);
+ QCOMPARE(object->grouped()->script().context(), qmlContext(object));
+}
+
+// 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"));
+ QEXPECT_FAIL("", "QTBUG-7860", Abort);
+ VERIFY_ERRORS(0);
+}
+
+// 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)
+{
+ 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());
+ } else {
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QCOMPARE(QString(object->metaObject()->className()), type);
+ }
+}
+
+QML_DECLARE_TYPE(TestType)
+QML_DECLARE_TYPE(TestType2)
+
+// Import tests (QT-558)
+
+void tst_qdeclarativelanguage::importsBuiltin_data()
+{
+ // QT-610
+
+ QTest::addColumn<QString>("qml");
+ QTest::addColumn<QString>("type");
+
+ // import built-ins
+ QTest::newRow("missing import")
+ << "Test {}"
+ << "";
+ QTest::newRow("not in version 0.0")
+ << "import com.nokia.Test 0.0\n"
+ "Test {}"
+ << "";
+ 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 {}"
+ << "";
+ 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 {}"
+ << "";
+ 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 {}"
+ << "TestType2";
+ QTest::newRow("multiversion 2")
+ << "import com.nokia.Test 1.11\n"
+ "import com.nokia.Test 1.12\n"
+ "OldTest {}"
+ << "TestType";
+ 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);
+ testType(qml,type);
+}
+
+void tst_qdeclarativelanguage::importsLocal_data()
+{
+ QTest::addColumn<QString>("qml");
+ QTest::addColumn<QString>("type");
+
+ // import locals
+ QTest::newRow("local import")
+ << "import \"subdir\"\n" // QT-613
+ "Test {}"
+ << "QDeclarativeRectangle";
+ QTest::newRow("local import second")
+ << "import Qt 4.6\nimport \"subdir\"\n"
+ "Test {}"
+ << "QDeclarativeRectangle";
+ QTest::newRow("local import subsubdir")
+ << "import Qt 4.6\nimport \"subdir/subsubdir\"\n"
+ "SubTest {}"
+ << "QDeclarativeRectangle";
+ QTest::newRow("local import QTBUG-7721 A")
+ << "subdir.Test {}" // no longer allowed (QTBUG-7721)
+ << "";
+ QTest::newRow("local import QTBUG-7721 B")
+ << "import \"subdir\" as X\n"
+ "X.subsubdir.SubTest {}" // no longer allowed (QTBUG-7721)
+ << "";
+ QTest::newRow("local import as")
+ << "import \"subdir\" as T\n"
+ "T.Test {}"
+ << "QDeclarativeRectangle";
+ QTest::newRow("wrong local import as")
+ << "import \"subdir\" as T\n"
+ "Test {}"
+ << "";
+ QTest::newRow("library precedence over local import")
+ << "import \"subdir\"\n"
+ "import com.nokia.Test 1.0\n"
+ "Test {}"
+ << "TestType";
+}
+
+void tst_qdeclarativelanguage::importsLocal()
+{
+ QFETCH(QString, qml);
+ QFETCH(QString, type);
+ testType(qml,type);
+}
+
+void tst_qdeclarativelanguage::importsRemote_data()
+{
+ QTest::addColumn<QString>("qml");
+ QTest::addColumn<QString>("type");
+
+ QString serverdir = "http://127.0.0.1:14445/qtest/declarative/qmllanguage";
+
+ QTest::newRow("remote import") << "import \""+serverdir+"\"\nTest {}" << "QDeclarativeRectangle";
+ QTest::newRow("remote import with subdir") << "import \""+serverdir+"\"\nTestSubDir {}" << "QDeclarativeText";
+ QTest::newRow("remote import with local") << "import \""+serverdir+"\"\nTestLocal {}" << "QDeclarativeImage";
+}
+
+#include "testhttpserver.h"
+
+void tst_qdeclarativelanguage::importsRemote()
+{
+ QFETCH(QString, qml);
+ QFETCH(QString, type);
+
+ TestHTTPServer server(14445);
+ server.serveDirectory(SRCDIR);
+
+ testType(qml,type);
+}
+
+void tst_qdeclarativelanguage::importsInstalled_data()
+{
+ // QT-610
+
+ QTest::addColumn<QString>("qml");
+ QTest::addColumn<QString>("type");
+
+ // import installed
+ QTest::newRow("installed import 0")
+ << "import com.nokia.installedtest 0.0\n"
+ "InstalledTestTP {}"
+ << "QDeclarativeRectangle";
+ QTest::newRow("installed import 0 as TP")
+ << "import com.nokia.installedtest 0.0 as TP\n"
+ "TP.InstalledTestTP {}"
+ << "QDeclarativeRectangle";
+ QTest::newRow("installed import 1")
+ << "import com.nokia.installedtest 1.0\n"
+ "InstalledTest {}"
+ << "QDeclarativeRectangle";
+ QTest::newRow("installed import 2")
+ << "import com.nokia.installedtest 1.3\n"
+ "InstalledTest {}"
+ << "QDeclarativeRectangle";
+ QTest::newRow("installed import 3")
+ << "import com.nokia.installedtest 1.4\n"
+ "InstalledTest {}"
+ << "QDeclarativeText";
+ QTest::newRow("installed import 4")
+ << "import com.nokia.installedtest 1.10\n"
+ "InstalledTest {}"
+ << "QDeclarativeText";
+ QTest::newRow("installed import visibility") // QT-614
+ << "import com.nokia.installedtest 1.4\n"
+ "PrivateType {}"
+ << "";
+}
+
+void tst_qdeclarativelanguage::importsInstalled()
+{
+ QFETCH(QString, qml);
+ QFETCH(QString, type);
+ testType(qml,type);
+}
+
+
+void tst_qdeclarativelanguage::importsOrder_data()
+{
+ QTest::addColumn<QString>("qml");
+ QTest::addColumn<QString>("type");
+
+ QTest::newRow("installed import overrides 1") <<
+ "import com.nokia.installedtest 1.0\n"
+ "import com.nokia.installedtest 1.4\n"
+ "InstalledTest {}"
+ << "QDeclarativeText";
+ QTest::newRow("installed import overrides 2") <<
+ "import com.nokia.installedtest 1.4\n"
+ "import com.nokia.installedtest 1.0\n"
+ "InstalledTest {}"
+ << "QDeclarativeRectangle";
+ 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 {}"
+ << "QDeclarativeText";
+ 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 {}"
+ << "QDeclarativeRectangle";
+
+ QTest::newRow("installed import versus builtin 1") <<
+ "import com.nokia.installedtest 1.5\n"
+ "import Qt 4.6\n"
+ "Rectangle {}"
+ << "QDeclarativeRectangle";
+ QTest::newRow("installed import versus builtin 2") <<
+ "import Qt 4.6\n"
+ "import com.nokia.installedtest 1.5\n"
+ "Rectangle {}"
+ << "QDeclarativeText";
+ QTest::newRow("namespaces cannot be overridden by types 1") <<
+ "import Qt 4.6 as Rectangle\n"
+ "import com.nokia.installedtest 1.5\n"
+ "Rectangle {}"
+ << "";
+ QTest::newRow("namespaces cannot be overridden by types 2") <<
+ "import Qt 4.6 as Rectangle\n"
+ "import com.nokia.installedtest 1.5\n"
+ "Rectangle.Image {}"
+ << "QDeclarativeImage";
+}
+
+void tst_qdeclarativelanguage::importsOrder()
+{
+ QFETCH(QString, qml);
+ QFETCH(QString, type);
+ testType(qml,type);
+}
+
+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 Qt 4.6\nComponent {}", QUrl());
+}
+
+void tst_qdeclarativelanguage::crash2()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("crash2.qml"));
+}
+
+
+void tst_qdeclarativelanguage::initTestCase()
+{
+ registerTypes();
+
+ QML_REGISTER_TYPE(com.nokia.Test, 0, 0, TestTP, TestType);
+ QML_REGISTER_TYPE(com.nokia.Test, 1, 0, Test, TestType);
+ QML_REGISTER_TYPE(com.nokia.Test, 1, 5, Test, TestType);
+ QML_REGISTER_TYPE(com.nokia.Test, 1, 8, Test, TestType2);
+ QML_REGISTER_TYPE(com.nokia.Test, 1, 9, OldTest, TestType);
+ QML_REGISTER_TYPE(com.nokia.Test, 1, 12, Test, TestType2);
+
+ // 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());
+ QVERIFY(in.open(QIODevice::ReadOnly));
+ QFile out(TEST_FILE(QString::fromUtf8("I18nType\303\201\303\242\303\243\303\244\303\245.qml")).toLocalFile());
+ QVERIFY(out.open(QIODevice::WriteOnly));
+ out.write(in.readAll());
+}
+
+QTEST_MAIN(tst_qdeclarativelanguage)
+
+#include "tst_qdeclarativelanguage.moc"
diff --git a/tests/auto/declarative/qdeclarativelistmodel/qdeclarativelistmodel.pro b/tests/auto/declarative/qdeclarativelistmodel/qdeclarativelistmodel.pro
new file mode 100644
index 0000000..d728d08
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelistmodel/qdeclarativelistmodel.pro
@@ -0,0 +1,6 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative
+QT += script
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qdeclarativelistmodel.cpp
diff --git a/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp
new file mode 100644
index 0000000..a1e6d6b
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp
@@ -0,0 +1,346 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QtDeclarative/private/qdeclarativelistmodel_p.h>
+#include <QtDeclarative/private/qdeclarativeexpression_p.h>
+#include <QDeclarativeComponent>
+#include <QDebug>
+
+class tst_QDeclarativeListModel : public QObject
+{
+ Q_OBJECT
+public:
+ tst_QDeclarativeListModel() {}
+
+private slots:
+ void static_types();
+ void static_types_data();
+ void static_i18n();
+ void static_nestedElements();
+ void static_nestedElements_data();
+ void dynamic_data();
+ void dynamic();
+ void error_data();
+ void error();
+};
+
+void tst_QDeclarativeListModel::static_i18n()
+{
+ QString expect = QString::fromUtf8("na\303\257ve");
+ QString componentStr = "import Qt 4.6\nListModel { ListElement { prop1: \""+expect+"\" } }";
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine);
+ component.setData(componentStr.toUtf8(), QUrl::fromLocalFile(""));
+ QDeclarativeListModel *obj = qobject_cast<QDeclarativeListModel*>(component.create());
+ QVERIFY(obj != 0);
+ QString prop = obj->get(0).property(QLatin1String("prop1")).toString();
+ QCOMPARE(prop,expect);
+ 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 Qt 4.6\n"
+ "ListModel {\n"
+ " ListElement {\n"
+ " attributes: [\n";
+ componentStr += elementsStr.toUtf8().constData();
+ componentStr +=
+ " ]\n"
+ " }\n"
+ "}";
+
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine);
+ component.setData(componentStr.toUtf8(), QUrl::fromLocalFile(""));
+
+ QDeclarativeListModel *obj = qobject_cast<QDeclarativeListModel*>(component.create());
+ QVERIFY(obj != 0);
+
+ QScriptValue prop = obj->get(0).property(QLatin1String("attributes")).property(QLatin1String("count"));
+ QVERIFY(prop.isNumber());
+ QCOMPARE(prop.toInt32(), qint32(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");
+
+ // Simple flat model
+
+ QTest::newRow("count") << "count" << 0 << "";
+
+ QTest::newRow("get1") << "{get(0)}" << 0 << "QML ListModel (unknown location) get: index 0 out of range";
+ QTest::newRow("get2") << "{get(-1)}" << 0 << "QML ListModel (unknown location) get: index -1 out of range";
+
+ QTest::newRow("append1") << "{append({'foo':123});count}" << 1 << "";
+ QTest::newRow("append2") << "{append({'foo':123,'bar':456});count}" << 1 << "";
+ QTest::newRow("append3a") << "{append({'foo':123});append({'foo':456});get(0).foo}" << 123 << "";
+ QTest::newRow("append3b") << "{append({'foo':123});append({'foo':456});get(1).foo}" << 456 << "";
+ QTest::newRow("append4a") << "{append(123)}" << 0 << "QML ListModel (unknown location) append: value is not an object";
+ QTest::newRow("append4b") << "{append([1,2,3])}" << 0 << "QML ListModel (unknown location) append: value is not an object";
+
+ QTest::newRow("clear1") << "{append({'foo':456});clear();count}" << 0 << "";
+ QTest::newRow("clear2") << "{append({'foo':123});append({'foo':456});clear();count}" << 0 << "";
+ QTest::newRow("clear2") << "{append({'foo':123});clear();get(0).foo}" << 0 << "QML ListModel (unknown location) get: index 0 out of range";
+
+ QTest::newRow("remove1") << "{append({'foo':123});remove(0);count}" << 0 << "";
+ QTest::newRow("remove2a") << "{append({'foo':123});append({'foo':456});remove(0);count}" << 1 << "";
+ QTest::newRow("remove2b") << "{append({'foo':123});append({'foo':456});remove(0);get(0).foo}" << 456 << "";
+ QTest::newRow("remove2c") << "{append({'foo':123});append({'foo':456});remove(1);get(0).foo}" << 123 << "";
+ QTest::newRow("remove3") << "{append({'foo':123});remove(0);get(0).foo}" << 0 << "QML ListModel (unknown location) get: index 0 out of range";
+ QTest::newRow("remove3a") << "{append({'foo':123});remove(-1)}" << 0 << "QML ListModel (unknown location) remove: index -1 out of range";
+ QTest::newRow("remove4a") << "{remove(0)}" << 0 << "QML ListModel (unknown location) remove: index 0 out of range";
+ QTest::newRow("remove4b") << "{append({'foo':123});remove(0);remove(0)}" << 0 << "QML ListModel (unknown location) remove: index 0 out of range";
+ QTest::newRow("remove4c") << "{append({'foo':123});remove(1)}" << 0 << "QML ListModel (unknown location) remove: index 1 out of range";
+
+ QTest::newRow("insert1") << "{insert(0,{'foo':123});count}" << 1 << "";
+ QTest::newRow("insert2") << "{insert(1,{'foo':123});count}" << 0 << "QML ListModel (unknown location) insert: index 1 out of range";
+ QTest::newRow("insert3a") << "{append({'foo':123});insert(1,{'foo':456});count}" << 2 << "";
+ QTest::newRow("insert3b") << "{append({'foo':123});insert(1,{'foo':456});get(0).foo}" << 123 << "";
+ QTest::newRow("insert3c") << "{append({'foo':123});insert(1,{'foo':456});get(1).foo}" << 456 << "";
+ QTest::newRow("insert3d") << "{append({'foo':123});insert(0,{'foo':456});get(0).foo}" << 456 << "";
+ QTest::newRow("insert3e") << "{append({'foo':123});insert(0,{'foo':456});get(1).foo}" << 123 << "";
+ QTest::newRow("insert4") << "{append({'foo':123});insert(-1,{'foo':456})}" << 0 << "QML ListModel (unknown location) insert: index -1 out of range";
+ QTest::newRow("insert5a") << "{insert(0,123)}" << 0 << "QML ListModel (unknown location) insert: value is not an object";
+ QTest::newRow("insert5b") << "{insert(0,[1,2,3])}" << 0 << "QML ListModel (unknown location) insert: value is not an object";
+
+ QTest::newRow("set1") << "{append({'foo':123});set(0,{'foo':456});count}" << 1 << "";
+ QTest::newRow("set2") << "{append({'foo':123});set(0,{'foo':456});get(0).foo}" << 456 << "";
+ QTest::newRow("set3a") << "{append({'foo':123,'bar':456});set(0,{'foo':999});get(0).foo}" << 999 << "";
+ QTest::newRow("set3b") << "{append({'foo':123,'bar':456});set(0,{'foo':999});get(0).bar}" << 456 << "";
+ QTest::newRow("set4a") << "{set(0,{'foo':456})}" << 0 << "QML ListModel (unknown location) set: index 0 out of range";
+ QTest::newRow("set4c") << "{set(-1,{'foo':456})}" << 0 << "QML ListModel (unknown location) set: index -1 out of range";
+ QTest::newRow("set5a") << "{append({'foo':123,'bar':456});set(0,123)}" << 0 << "QML ListModel (unknown location) set: value is not an object";
+ QTest::newRow("set5b") << "{append({'foo':123,'bar':456});set(0,[1,2,3])}" << 0 << "QML ListModel (unknown location) set: value is not an object";
+ QTest::newRow("set6") << "{append({'foo':123});set(1,{'foo':456});count}" << 2 << "";
+
+ QTest::newRow("setprop1") << "{append({'foo':123});setProperty(0,'foo',456);count}" << 1 << "";
+ QTest::newRow("setprop2") << "{append({'foo':123});setProperty(0,'foo',456);get(0).foo}" << 456 << "";
+ QTest::newRow("setprop3a") << "{append({'foo':123,'bar':456});setProperty(0,'foo',999);get(0).foo}" << 999 << "";
+ QTest::newRow("setprop3b") << "{append({'foo':123,'bar':456});setProperty(0,'foo',999);get(0).bar}" << 456 << "";
+ QTest::newRow("setprop4a") << "{setProperty(0,'foo',456)}" << 0 << "QML ListModel (unknown location) set: index 0 out of range";
+ QTest::newRow("setprop4b") << "{setProperty(-1,'foo',456)}" << 0 << "QML ListModel (unknown location) set: index -1 out of range";
+ QTest::newRow("setprop4c") << "{append({'foo':123,'bar':456});setProperty(1,'foo',456)}" << 0 << "QML ListModel (unknown location) set: index 1 out of range";
+ QTest::newRow("setprop5") << "{append({'foo':123,'bar':456});append({'foo':111});setProperty(1,'bar',222);get(1).bar}" << 222 << "";
+
+ QTest::newRow("move1a") << "{append({'foo':123});append({'foo':456});move(0,1,1);count}" << 2 << "";
+ QTest::newRow("move1b") << "{append({'foo':123});append({'foo':456});move(0,1,1);get(0).foo}" << 456 << "";
+ QTest::newRow("move1c") << "{append({'foo':123});append({'foo':456});move(0,1,1);get(1).foo}" << 123 << "";
+ QTest::newRow("move1d") << "{append({'foo':123});append({'foo':456});move(1,0,1);get(0).foo}" << 456 << "";
+ QTest::newRow("move1e") << "{append({'foo':123});append({'foo':456});move(1,0,1);get(1).foo}" << 123 << "";
+ QTest::newRow("move2a") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(0,1,2);count}" << 3 << "";
+ QTest::newRow("move2b") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(0,1,2);get(0).foo}" << 789 << "";
+ QTest::newRow("move2c") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(0,1,2);get(1).foo}" << 123 << "";
+ QTest::newRow("move2d") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(0,1,2);get(2).foo}" << 456 << "";
+ QTest::newRow("move3a") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(1,0,3)}" << 0 << "QML ListModel (unknown location) move: out of range";
+ QTest::newRow("move3b") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(1,-1,1)}" << 0 << "QML ListModel (unknown location) move: out of range";
+ QTest::newRow("move3c") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(1,0,-1)}" << 0 << "QML ListModel (unknown location) move: out of range";
+ QTest::newRow("move3d") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(0,3,1)}" << 0 << "QML ListModel (unknown location) move: out of range";
+
+ // Structured model
+
+ QTest::newRow("listprop1a") << "{append({'foo':123,'bars':[{'a':1},{'a':2},{'a':3}]});count}" << 1 << "";
+ QTest::newRow("listprop1b") << "{append({'foo':123,'bars':[{'a':1},{'a':2},{'a':3}]});get(0).bars.get(1).a}" << 2 << "";
+ QTest::newRow("listprop2a") << "{append({'foo':123,'bars':[{'a':1},{'a':2},{'a':3}]});get(0).bars.append({'a':4});get(0).bars.get(3).a}" << 4 << "";
+}
+
+void tst_QDeclarativeListModel::dynamic()
+{
+ QFETCH(QString, script);
+ QFETCH(int, result);
+ QFETCH(QString, warning);
+
+ QDeclarativeEngine engine;
+ QDeclarativeListModel model;
+ QDeclarativeEngine::setContextForObject(&model,engine.rootContext());
+ engine.rootContext()->addDefaultObject(&model);
+ QDeclarativeExpression e(engine.rootContext(), script, &model);
+ if (!warning.isEmpty())
+ QTest::ignoreMessage(QtWarningMsg, warning.toLatin1());
+ int actual = e.value().toInt();
+ if (e.hasError())
+ qDebug() << e.error(); // errors not expected
+ QVERIFY(!e.hasError());
+ QCOMPARE(actual,result);
+}
+
+void tst_QDeclarativeListModel::static_types_data()
+{
+ QTest::addColumn<QString>("qml");
+ QTest::addColumn<QVariant>("value");
+
+ QTest::newRow("string")
+ << "ListElement { foo: \"bar\" }"
+ << QVariant(QString("bar"));
+
+ QTest::newRow("real")
+ << "ListElement { foo: 10.5 }"
+ << QVariant(10.5);
+
+ QTest::newRow("real0")
+ << "ListElement { foo: 0 }"
+ << QVariant(double(0));
+
+ QTest::newRow("bool")
+ << "ListElement { foo: false }"
+ << QVariant(false);
+
+ QTest::newRow("bool")
+ << "ListElement { foo: true }"
+ << QVariant(true);
+
+ QTest::newRow("enum")
+ << "ListElement { foo: Text.AlignHCenter }"
+ << QVariant("QTBUG-5974:ListElement: constant script support for property value");
+}
+
+void tst_QDeclarativeListModel::static_types()
+{
+ QFETCH(QString, qml);
+ QFETCH(QVariant, value);
+
+ qml = "import Qt 4.6\nListModel { " + qml + " }";
+
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine);
+ component.setData(qml.toUtf8(),
+ QUrl::fromLocalFile(QString("dummy.qml")));
+
+ if (value.toString().startsWith("QTBUG-"))
+ QEXPECT_FAIL("",value.toString().toLatin1(),Abort);
+
+ QVERIFY(!component.isError());
+
+ QDeclarativeListModel *obj = qobject_cast<QDeclarativeListModel*>(component.create());
+ QVERIFY(obj != 0);
+
+ QScriptValue actual = obj->get(0).property(QLatin1String("foo"));
+
+ QCOMPARE(actual.isString(), value.type() == QVariant::String);
+ QCOMPARE(actual.isBoolean(), value.type() == QVariant::Bool);
+ QCOMPARE(actual.isNumber(), value.type() == QVariant::Double);
+
+ QCOMPARE(actual.toString(), value.toString());
+
+ delete obj;
+}
+
+void tst_QDeclarativeListModel::error_data()
+{
+ QTest::addColumn<QString>("qml");
+ QTest::addColumn<QString>("error");
+
+ QTest::newRow("id not allowed in ListElement")
+ << "import Qt 4.6\nListModel { ListElement { id: fred } }"
+ << "ListElement: cannot use reserved \"id\" property";
+
+ QTest::newRow("id allowed in ListModel")
+ << "import Qt 4.6\nListModel { id:model }"
+ << "";
+
+ QTest::newRow("random properties not allowed in ListModel")
+ << "import Qt 4.6\nListModel { foo:123 }"
+ << "ListModel: undefined property 'foo'";
+
+ QTest::newRow("random properties allowed in ListElement")
+ << "import Qt 4.6\nListModel { ListElement { foo:123 } }"
+ << "";
+
+ QTest::newRow("bindings not allowed in ListElement")
+ << "import Qt 4.6\nRectangle { id: rect; ListModel { ListElement { foo: rect.color } } }"
+ << "ListElement: cannot use script for property value"; // but note QTBUG-5974
+
+ QTest::newRow("random object list properties allowed in ListElement")
+ << "import Qt 4.6\nListModel { ListElement { foo: [ ListElement { bar: 123 } ] } }"
+ << "";
+
+ QTest::newRow("default properties not allowed in ListElement")
+ << "import Qt 4.6\nListModel { ListElement { Item { } } }"
+ << "QTBUG-6082 ListElement should not allow child objects";
+}
+
+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 {
+ if (error.startsWith(QLatin1String("QTBUG-")))
+ QEXPECT_FAIL("",error.toLatin1(),Abort);
+ QVERIFY(component.isError());
+ QList<QDeclarativeError> errors = component.errors();
+ QCOMPARE(errors.count(),1);
+ QCOMPARE(errors.at(0).description(),error);
+ }
+}
+
+QTEST_MAIN(tst_QDeclarativeListModel)
+
+#include "tst_qdeclarativelistmodel.moc"
diff --git a/tests/auto/declarative/qmllist/data/MyType.qml b/tests/auto/declarative/qdeclarativelistreference/data/MyType.qml
index d08f35b..d08f35b 100644
--- a/tests/auto/declarative/qmllist/data/MyType.qml
+++ b/tests/auto/declarative/qdeclarativelistreference/data/MyType.qml
diff --git a/tests/auto/declarative/qmllist/data/engineTypes.qml b/tests/auto/declarative/qdeclarativelistreference/data/engineTypes.qml
index 670aee4..670aee4 100644
--- a/tests/auto/declarative/qmllist/data/engineTypes.qml
+++ b/tests/auto/declarative/qdeclarativelistreference/data/engineTypes.qml
diff --git a/tests/auto/declarative/qmllist/data/variantToList.qml b/tests/auto/declarative/qdeclarativelistreference/data/variantToList.qml
index 0c2d0aa..0c2d0aa 100644
--- a/tests/auto/declarative/qmllist/data/variantToList.qml
+++ b/tests/auto/declarative/qdeclarativelistreference/data/variantToList.qml
diff --git a/tests/auto/declarative/qdeclarativelistreference/qdeclarativelistreference.pro b/tests/auto/declarative/qdeclarativelistreference/qdeclarativelistreference.pro
new file mode 100644
index 0000000..0c9b2d9
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelistreference/qdeclarativelistreference.pro
@@ -0,0 +1,5 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qdeclarativelistreference.cpp
diff --git a/tests/auto/declarative/qdeclarativelistreference/tst_qdeclarativelistreference.cpp b/tests/auto/declarative/qdeclarativelistreference/tst_qdeclarativelistreference.cpp
new file mode 100644
index 0000000..1b7af19
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelistreference/tst_qdeclarativelistreference.cpp
@@ -0,0 +1,580 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <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>
+
+inline QUrl TEST_FILE(const QString &filename)
+{
+ QFileInfo fileInfo(__FILE__);
+ return QUrl::fromLocalFile(fileInfo.absoluteDir().filePath("data/" + filename));
+}
+
+inline QUrl TEST_FILE(const char *filename)
+{
+ return TEST_FILE(QLatin1String(filename));
+}
+
+class tst_qdeclarativelistreference : public QObject
+{
+ 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;
+};
+QML_DECLARE_TYPE(TestType);
+
+void tst_qdeclarativelistreference::initTestCase()
+{
+ QML_REGISTER_NOCREATE_TYPE(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, TEST_FILE("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, TEST_FILE("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/qdeclarativelistview/data/displaylist.qml b/tests/auto/declarative/qdeclarativelistview/data/displaylist.qml
new file mode 100644
index 0000000..7b124a5
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelistview/data/displaylist.qml
@@ -0,0 +1,43 @@
+import Qt 4.6
+
+Rectangle {
+ width: 240
+ height: 320
+ color: "#ffffff"
+ resources: [
+ Component {
+ id: myDelegate
+ Rectangle {
+ id: wrapper
+ objectName: "wrapper"
+ height: 20
+ width: 240
+ Text {
+ text: index
+ }
+ Text {
+ x: 30
+ objectName: "displayText"
+ text: display
+ }
+ color: ListView.isCurrentItem ? "lightsteelblue" : "white"
+ }
+ },
+ Component {
+ id: myHighlight
+ Rectangle { color: "green" }
+ }
+ ]
+ ListView {
+ id: list
+ objectName: "list"
+ focus: true
+ width: 240
+ height: 320
+ model: testModel
+ delegate: myDelegate
+ highlight: myHighlight
+ highlightMoveSpeed: 1000
+ highlightResizeSpeed: 1000
+ }
+}
diff --git a/tests/auto/declarative/qmlgraphicslistview/data/itemlist.qml b/tests/auto/declarative/qdeclarativelistview/data/itemlist.qml
index e6b5c8f..e6b5c8f 100644
--- a/tests/auto/declarative/qmlgraphicslistview/data/itemlist.qml
+++ b/tests/auto/declarative/qdeclarativelistview/data/itemlist.qml
diff --git a/tests/auto/declarative/qmlgraphicslistview/data/listview-enforcerange.qml b/tests/auto/declarative/qdeclarativelistview/data/listview-enforcerange.qml
index 46fddae..46fddae 100644
--- a/tests/auto/declarative/qmlgraphicslistview/data/listview-enforcerange.qml
+++ b/tests/auto/declarative/qdeclarativelistview/data/listview-enforcerange.qml
diff --git a/tests/auto/declarative/qmlgraphicslistview/data/listview-initCurrent.qml b/tests/auto/declarative/qdeclarativelistview/data/listview-initCurrent.qml
index 74f5ef4..74f5ef4 100644
--- a/tests/auto/declarative/qmlgraphicslistview/data/listview-initCurrent.qml
+++ b/tests/auto/declarative/qdeclarativelistview/data/listview-initCurrent.qml
diff --git a/tests/auto/declarative/qmlgraphicslistview/data/listview-sections.qml b/tests/auto/declarative/qdeclarativelistview/data/listview-sections.qml
index 4b5bea6..4b5bea6 100644
--- a/tests/auto/declarative/qmlgraphicslistview/data/listview-sections.qml
+++ b/tests/auto/declarative/qdeclarativelistview/data/listview-sections.qml
diff --git a/tests/auto/declarative/qdeclarativelistview/data/listview.qml b/tests/auto/declarative/qdeclarativelistview/data/listview.qml
new file mode 100644
index 0000000..1c1b3f8
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelistview/data/listview.qml
@@ -0,0 +1,119 @@
+import Qt 4.6
+
+Rectangle {
+ width: 240
+ height: 320
+ color: "#ffffff"
+ function checkProperties() {
+ testObject.error = false;
+ if (list.model != testModel) {
+ console.log("model property incorrect");
+ testObject.error = true;
+ }
+ if (!testObject.animate && list.delegate != myDelegate) {
+ console.log("delegate property incorrect - expected myDelegate");
+ testObject.error = true;
+ }
+ if (testObject.animate && list.delegate != animatedDelegate) {
+ console.log("delegate property incorrect - expected animatedDelegate");
+ testObject.error = true;
+ }
+ if (testObject.invalidHighlight && list.highlight != invalidHl) {
+ console.log("highlight property incorrect - expected invalidHl");
+ testObject.error = true;
+ }
+ if (!testObject.invalidHighlight && list.highlight != myHighlight) {
+ console.log("highlight property incorrect - expected myHighlight");
+ testObject.error = true;
+ }
+ }
+ resources: [
+ Component {
+ id: myDelegate
+ Rectangle {
+ id: wrapper
+ objectName: "wrapper"
+ height: 20
+ width: 240
+ Text {
+ text: index
+ }
+ Text {
+ x: 30
+ id: textName
+ objectName: "textName"
+ text: name
+ }
+ Text {
+ x: 120
+ id: textNumber
+ objectName: "textNumber"
+ text: number
+ }
+ Text {
+ x: 200
+ text: wrapper.y
+ }
+ color: ListView.isCurrentItem ? "lightsteelblue" : "white"
+ }
+ },
+ Component {
+ id: animatedDelegate
+ Rectangle {
+ id: wrapper
+ objectName: "wrapper"
+ height: 20
+ width: 240
+ Text {
+ text: index
+ }
+ Text {
+ x: 30
+ id: textName
+ objectName: "textName"
+ text: name
+ }
+ Text {
+ x: 120
+ id: textNumber
+ objectName: "textNumber"
+ text: number
+ }
+ Text {
+ x: 200
+ text: wrapper.y
+ }
+ color: ListView.isCurrentItem ? "lightsteelblue" : "white"
+ ListView.onRemove: SequentialAnimation {
+ ScriptAction { script: console.log("Fix PropertyAction with attached properties") }
+/*
+ PropertyAction { target: wrapper; property: "ListView.delayRemove"; value: true }
+ NumberAnimation { target: wrapper; property: "scale"; to: 0; duration: 250; easing.type: "InOutQuad" }
+ PropertyAction { target: wrapper; property: "ListView.delayRemove"; value: false }
+*/
+ }
+ }
+ },
+ Component {
+ id: myHighlight
+ Rectangle { color: "green" }
+ },
+ Component {
+ id: invalidHl
+ EaseFollow {}
+ }
+ ]
+ ListView {
+ id: list
+ objectName: "list"
+ focus: true
+ width: 240
+ height: 320
+ model: testModel
+ delegate: testObject.animate ? animatedDelegate : myDelegate
+ highlight: testObject.invalidHighlight ? invalidHl : myHighlight
+ highlightMoveSpeed: 1000
+ highlightResizeSpeed: 1000
+ cacheBuffer: testObject.cacheBuffer
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativelistview/qdeclarativelistview.pro b/tests/auto/declarative/qdeclarativelistview/qdeclarativelistview.pro
new file mode 100644
index 0000000..3a076f8
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelistview/qdeclarativelistview.pro
@@ -0,0 +1,8 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qdeclarativelistview.cpp
+
+# Define SRCDIR equal to test's source directory
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
new file mode 100644
index 0000000..f15f26b
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
@@ -0,0 +1,1413 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QtTest/QtTest>
+#include <QStringListModel>
+#include <private/qlistmodelinterface_p.h>
+#include <qdeclarativeview.h>
+#include <private/qdeclarativelistview_p.h>
+#include <private/qdeclarativetext_p.h>
+#include <private/qdeclarativevisualitemmodel_p.h>
+#include <qdeclarativecontext.h>
+#include <qdeclarativeexpression.h>
+
+class tst_QDeclarativeListView : public QObject
+{
+ Q_OBJECT
+public:
+ tst_QDeclarativeListView();
+
+private slots:
+ // Test both QListModelInterface and QAbstractItemModel model types
+ void qListModelInterface_items();
+ void qAbstractItemModel_items();
+
+ void qListModelInterface_changed();
+ void qAbstractItemModel_changed();
+
+ void qListModelInterface_inserted();
+ void qAbstractItemModel_inserted();
+
+ void qListModelInterface_removed();
+ void qAbstractItemModel_removed();
+
+ void qListModelInterface_moved();
+ void qAbstractItemModel_moved();
+
+ void qListModelInterface_clear();
+ void qAbstractItemModel_clear();
+
+ void itemList();
+ void currentIndex();
+ void enforceRange();
+ void spacing();
+ void sections();
+ void cacheBuffer();
+ void positionViewAtIndex();
+ void resetModel();
+
+private:
+ template <class T> void items();
+ template <class T> void changed();
+ template <class T> void inserted();
+ template <class T> void removed(bool animated);
+ template <class T> void moved();
+ template <class T> void clear();
+ QDeclarativeView *createView();
+ template<typename T>
+ T *findItem(QGraphicsObject *parent, const QString &id, int index=-1);
+ template<typename T>
+ QList<T*> findItems(QGraphicsObject *parent, const QString &objectName);
+ void dumpTree(QDeclarativeItem *parent, int depth = 0);
+};
+
+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;
+};
+
+class TestModel : public QListModelInterface
+{
+ Q_OBJECT
+public:
+ TestModel(QObject *parent = 0) : QListModelInterface(parent) {}
+ ~TestModel() {}
+
+ enum Roles { Name, Number };
+
+ QString name(int index) const { return list.at(index).first; }
+ QString number(int index) const { return list.at(index).second; }
+
+ int count() const { return list.count(); }
+
+ QList<int> roles() const { return QList<int>() << Name << Number; }
+ QString toString(int role) const {
+ switch(role) {
+ case Name:
+ return "name";
+ case Number:
+ return "number";
+ default:
+ return "";
+ }
+ }
+
+ QVariant 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> 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 addItem(const QString &name, const QString &number) {
+ list.append(QPair<QString,QString>(name, number));
+ emit itemsInserted(list.count()-1, 1);
+ }
+
+ void insertItem(int index, const QString &name, const QString &number) {
+ list.insert(index, QPair<QString,QString>(name, number));
+ emit itemsInserted(index, 1);
+ }
+
+ void removeItem(int index) {
+ list.removeAt(index);
+ emit itemsRemoved(index, 1);
+ }
+
+ void moveItem(int from, int to) {
+ list.move(from, to);
+ emit itemsMoved(from, to, 1);
+ }
+
+ void modifyItem(int index, const QString &name, const QString &number) {
+ list[index] = QPair<QString,QString>(name, number);
+ emit itemsChanged(index, 1, roles());
+ }
+
+ void clear() {
+ int count = list.count();
+ list.clear();
+ emit itemsRemoved(0, count);
+ }
+
+private:
+ QList<QPair<QString,QString> > list;
+};
+
+
+class TestModel2 : public QAbstractListModel
+{
+public:
+ enum Roles { Name = Qt::UserRole+1, Number = Qt::UserRole+2 };
+
+ TestModel2(QObject *parent=0) : QAbstractListModel(parent) {
+ QHash<int, QByteArray> roles;
+ roles[Name] = "name";
+ roles[Number] = "number";
+ setRoleNames(roles);
+ }
+
+ int rowCount(const QModelIndex &parent=QModelIndex()) const { return list.count(); }
+ QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) 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 count() const { return rowCount(); }
+ QString name(int index) const { return list.at(index).first; }
+ QString number(int index) const { return list.at(index).second; }
+
+ void addItem(const QString &name, const QString &number) {
+ emit beginInsertRows(QModelIndex(), list.count(), list.count());
+ list.append(QPair<QString,QString>(name, number));
+ emit endInsertRows();
+ }
+
+ void 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 removeItem(int index) {
+ emit beginRemoveRows(QModelIndex(), index, index);
+ list.removeAt(index);
+ emit endRemoveRows();
+ }
+
+ void moveItem(int from, int to) {
+ emit beginMoveRows(QModelIndex(), from, from, QModelIndex(), to);
+ list.move(from, to);
+ emit endMoveRows();
+ }
+
+ void 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 clear() {
+ int count = list.count();
+ emit beginRemoveRows(QModelIndex(), 0, count-1);
+ list.clear();
+ emit endRemoveRows();
+ }
+
+private:
+ QList<QPair<QString,QString> > list;
+};
+
+tst_QDeclarativeListView::tst_QDeclarativeListView()
+{
+}
+
+template <class T>
+void tst_QDeclarativeListView::items()
+{
+ QDeclarativeView *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(QUrl::fromLocalFile(SRCDIR "/data/listview.qml"));
+ qApp->processEvents();
+
+ QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list");
+ QVERIFY(listview != 0);
+
+ QDeclarativeItem *viewport = listview->viewport();
+ QVERIFY(viewport != 0);
+
+ QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
+ QVERIFY(testObject->error() == false);
+
+ QVERIFY(listview->highlightItem() != 0);
+ QCOMPARE(listview->count(), model.count());
+ QCOMPARE(viewport->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
+
+ // current item should be first item
+ QCOMPARE(listview->currentItem(), findItem<QDeclarativeItem>(viewport, "wrapper", 0));
+
+ for (int i = 0; i < model.count(); ++i) {
+ QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", i);
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), model.name(i));
+ QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", i);
+ QVERIFY(number != 0);
+ QCOMPARE(number->text(), model.number(i));
+ }
+
+ // switch to other delegate
+ testObject->setAnimate(true);
+ QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
+ QVERIFY(testObject->error() == false);
+ QVERIFY(listview->currentItem());
+
+ // set invalid highlight
+ testObject->setInvalidHighlight(true);
+ QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
+ QVERIFY(testObject->error() == false);
+ QVERIFY(listview->currentItem());
+ QVERIFY(listview->highlightItem() == 0);
+
+ // back to normal highlight
+ testObject->setInvalidHighlight(false);
+ QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
+ QVERIFY(testObject->error() == false);
+ QVERIFY(listview->currentItem());
+ QVERIFY(listview->highlightItem() != 0);
+
+ // set an empty model and confirm that items are destroyed
+ T model2;
+ ctxt->setContextProperty("testModel", &model2);
+
+ // Allow deleteLaters to process
+ QTest::qWait(500);
+
+ int itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ QVERIFY(itemCount == 0);
+
+ QCOMPARE(listview->highlightResizeSpeed(), 1000.0);
+ QCOMPARE(listview->highlightMoveSpeed(), 1000.0);
+
+ delete canvas;
+}
+
+template <class T>
+void tst_QDeclarativeListView::changed()
+{
+ QDeclarativeView *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(QUrl::fromLocalFile(SRCDIR "/data/listview.qml"));
+ qApp->processEvents();
+
+ QDeclarativeFlickable *listview = findItem<QDeclarativeFlickable>(canvas->rootObject(), "list");
+ QVERIFY(listview != 0);
+
+ QDeclarativeItem *viewport = listview->viewport();
+ QVERIFY(viewport != 0);
+
+ model.modifyItem(1, "Will", "9876");
+ QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", 1);
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), model.name(1));
+ QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", 1);
+ QVERIFY(number != 0);
+ QCOMPARE(number->text(), model.number(1));
+
+ delete canvas;
+}
+
+template <class T>
+void tst_QDeclarativeListView::inserted()
+{
+ QDeclarativeView *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(QUrl::fromLocalFile(SRCDIR "/data/listview.qml"));
+ qApp->processEvents();
+
+ QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list");
+ QVERIFY(listview != 0);
+
+ QDeclarativeItem *viewport = listview->viewport();
+ QVERIFY(viewport != 0);
+
+ model.insertItem(1, "Will", "9876");
+
+ // let transitions settle.
+ QTest::qWait(500);
+
+ QCOMPARE(viewport->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
+
+ QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", 1);
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), model.name(1));
+ QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", 1);
+ QVERIFY(number != 0);
+ QCOMPARE(number->text(), model.number(1));
+
+ // Confirm items positioned correctly
+ for (int i = 0; i < model.count(); ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QCOMPARE(item->y(), i*20.0);
+ }
+
+ model.insertItem(0, "Foo", "1111"); // zero index, and current item
+
+ // let transitions settle.
+ QTest::qWait(500);
+
+ QCOMPARE(viewport->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
+
+ name = findItem<QDeclarativeText>(viewport, "textName", 0);
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), model.name(0));
+ number = findItem<QDeclarativeText>(viewport, "textNumber", 0);
+ QVERIFY(number != 0);
+ QCOMPARE(number->text(), model.number(0));
+
+ QCOMPARE(listview->currentIndex(), 1);
+
+ // Confirm items positioned correctly
+ for (int i = 0; i < model.count(); ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QCOMPARE(item->y(), i*20.0);
+ }
+
+ for (int i = model.count(); i < 30; ++i)
+ model.insertItem(i, "Hello", QString::number(i));
+ QTest::qWait(500);
+
+ listview->setContentY(80);
+ QTest::qWait(500);
+
+ // Insert item outside visible area
+ model.insertItem(1, "Hello", "1324");
+ QTest::qWait(500);
+
+ QVERIFY(listview->contentY() == 80);
+
+ // Confirm items positioned correctly
+ for (int i = 5; i < 5+15; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QVERIFY(item);
+ QCOMPARE(item->y(), i*20.0 - 20.0);
+ }
+
+// QCOMPARE(listview->viewportHeight(), model.count() * 20.0);
+
+ delete canvas;
+}
+
+template <class T>
+void tst_QDeclarativeListView::removed(bool animated)
+{
+ QDeclarativeView *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;
+ testObject->setAnimate(animated);
+ ctxt->setContextProperty("testObject", testObject);
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listview.qml"));
+ qApp->processEvents();
+
+ QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list");
+ QVERIFY(listview != 0);
+
+ QDeclarativeItem *viewport = listview->viewport();
+ QVERIFY(viewport != 0);
+
+ model.removeItem(1);
+
+ // let transitions settle.
+ QTest::qWait(500);
+
+ QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", 1);
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), model.name(1));
+ QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", 1);
+ QVERIFY(number != 0);
+ QCOMPARE(number->text(), model.number(1));
+
+ // Confirm items positioned correctly
+ int itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QVERIFY(item);
+ QVERIFY(item->y() == i*20);
+ }
+
+ // Remove first item (which is the current item);
+ model.removeItem(0); // post: top item starts at 20
+
+ // let transitions settle.
+ QTest::qWait(500);
+
+ name = findItem<QDeclarativeText>(viewport, "textName", 0);
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), model.name(0));
+ number = findItem<QDeclarativeText>(viewport, "textNumber", 0);
+ QVERIFY(number != 0);
+ QCOMPARE(number->text(), model.number(0));
+
+ // Confirm items positioned correctly
+ itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QVERIFY(item);
+ QCOMPARE(item->y(),i*20.0 + 20.0);
+ }
+
+ // Remove items not visible
+ model.removeItem(18);
+ // let transitions settle.
+ QTest::qWait(500);
+
+ // Confirm items positioned correctly
+ itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QVERIFY(item);
+ QCOMPARE(item->y(),i*20.0+20.0);
+ }
+
+ // Remove items before visible
+ listview->setContentY(80);
+ listview->setCurrentIndex(10);
+
+ model.removeItem(1); // post: top item will be at 40
+ // let transitions settle.
+ QTest::qWait(500);
+
+ // Confirm items positioned correctly
+ for (int i = 2; i < 18; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QVERIFY(item);
+ QCOMPARE(item->y(),40+i*20.0);
+ }
+
+ // Remove current index
+ QVERIFY(listview->currentIndex() == 9);
+ QDeclarativeItem *oldCurrent = listview->currentItem();
+ model.removeItem(9);
+ QTest::qWait(500);
+
+ QCOMPARE(listview->currentIndex(), 9);
+ QVERIFY(listview->currentItem() != oldCurrent);
+
+ listview->setContentY(40); // That's the top now
+ // let transitions settle.
+ QTest::qWait(500);
+
+ // Confirm items positioned correctly
+ itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QVERIFY(item);
+ QCOMPARE(item->y(),40+i*20.0);
+ }
+
+ // remove current item beyond visible items.
+ listview->setCurrentIndex(20);
+ QTest::qWait(500);
+ listview->setContentY(40);
+ model.removeItem(20);
+ QTest::qWait(500);
+
+ QCOMPARE(listview->currentIndex(), 20);
+ QVERIFY(listview->currentItem() != 0);
+
+ // remove item before current, but visible
+ listview->setCurrentIndex(8);
+ QTest::qWait(500);
+ oldCurrent = listview->currentItem();
+ model.removeItem(6);
+ QTest::qWait(500);
+
+ QCOMPARE(listview->currentIndex(), 7);
+ QVERIFY(listview->currentItem() == oldCurrent);
+
+ delete canvas;
+}
+
+template <class T>
+void tst_QDeclarativeListView::clear()
+{
+ QDeclarativeView *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(QUrl::fromLocalFile(SRCDIR "/data/listview.qml"));
+ qApp->processEvents();
+
+ QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list");
+ QVERIFY(listview != 0);
+
+ QDeclarativeItem *viewport = listview->viewport();
+ QVERIFY(viewport != 0);
+
+ model.clear();
+
+ // let transitions settle.
+ QTest::qWait(500);
+
+ QVERIFY(listview->count() == 0);
+ QVERIFY(listview->currentItem() == 0);
+ QVERIFY(listview->contentY() == 0);
+
+ delete canvas;
+}
+
+
+template <class T>
+void tst_QDeclarativeListView::moved()
+{
+ QDeclarativeView *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(QUrl::fromLocalFile(SRCDIR "/data/listview.qml"));
+ qApp->processEvents();
+
+ QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list");
+ QVERIFY(listview != 0);
+
+ QDeclarativeItem *viewport = listview->viewport();
+ QVERIFY(viewport != 0);
+
+ model.moveItem(1, 4);
+
+ // let transitions settle.
+ QTest::qWait(500);
+
+ QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", 1);
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), model.name(1));
+ QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", 1);
+ QVERIFY(number != 0);
+ QCOMPARE(number->text(), model.number(1));
+
+ name = findItem<QDeclarativeText>(viewport, "textName", 4);
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), model.name(4));
+ number = findItem<QDeclarativeText>(viewport, "textNumber", 4);
+ QVERIFY(number != 0);
+ QCOMPARE(number->text(), model.number(4));
+
+ // Confirm items positioned correctly
+ int itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QVERIFY(item);
+ QVERIFY(item->y() == i*20);
+ }
+
+ listview->setContentY(80);
+
+ // move outside visible area
+ model.moveItem(1, 18);
+
+ // let transitions settle.
+ QTest::qWait(500);
+
+ // Confirm items positioned correctly and indexes correct
+ for (int i = 3; i < model.count() && i < itemCount; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QVERIFY(item);
+ QCOMPARE(item->y(), i*20.0 + 20);
+ name = findItem<QDeclarativeText>(viewport, "textName", i);
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), model.name(i));
+ number = findItem<QDeclarativeText>(viewport, "textNumber", i);
+ QVERIFY(number != 0);
+ QCOMPARE(number->text(), model.number(i));
+ }
+
+ // move from outside visible into visible
+ model.moveItem(20, 4);
+
+ // let transitions settle.
+ QTest::qWait(500);
+
+ // Confirm items positioned correctly and indexes correct
+ for (int i = 3; i < model.count() && i < itemCount; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QVERIFY(item);
+ QCOMPARE(item->y(), i*20.0 + 20);
+ name = findItem<QDeclarativeText>(viewport, "textName", i);
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), model.name(i));
+ number = findItem<QDeclarativeText>(viewport, "textNumber", i);
+ QVERIFY(number != 0);
+ QCOMPARE(number->text(), model.number(i));
+ }
+
+ delete canvas;
+}
+
+void tst_QDeclarativeListView::enforceRange()
+{
+ QDeclarativeView *canvas = createView();
+
+ TestModel model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QDeclarativeContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listview-enforcerange.qml"));
+ qApp->processEvents();
+
+ QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list");
+ QVERIFY(listview != 0);
+
+ QCOMPARE(listview->preferredHighlightBegin(), 100.0);
+ QCOMPARE(listview->preferredHighlightEnd(), 100.0);
+ QCOMPARE(listview->highlightRangeMode(), QDeclarativeListView::StrictlyEnforceRange);
+
+ QDeclarativeItem *viewport = listview->viewport();
+ QVERIFY(viewport != 0);
+
+ // view should be positioned at the top of the range.
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", 0);
+ QVERIFY(item);
+ QCOMPARE(listview->contentY(), -100.0);
+
+ QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", 0);
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), model.name(0));
+ QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", 0);
+ QVERIFY(number != 0);
+ QCOMPARE(number->text(), model.number(0));
+
+ // Check currentIndex is updated when viewport moves
+ listview->setContentY(20);
+ QTest::qWait(500);
+
+ QCOMPARE(listview->currentIndex(), 6);
+
+ delete canvas;
+}
+
+void tst_QDeclarativeListView::spacing()
+{
+ QDeclarativeView *canvas = createView();
+
+ TestModel 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(QUrl::fromLocalFile(SRCDIR "/data/listview.qml"));
+ qApp->processEvents();
+
+ QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list");
+ QVERIFY(listview != 0);
+
+ QDeclarativeItem *viewport = listview->viewport();
+ QVERIFY(viewport != 0);
+
+ // Confirm items positioned correctly
+ int itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QVERIFY(item);
+ QVERIFY(item->y() == i*20);
+ }
+
+ listview->setSpacing(10);
+ QVERIFY(listview->spacing() == 10);
+
+ // Confirm items positioned correctly
+ itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QVERIFY(item);
+ QVERIFY(item->y() == i*30);
+ }
+
+ listview->setSpacing(0);
+
+ // Confirm items positioned correctly
+ itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QVERIFY(item);
+ QCOMPARE(item->y(), i*20.0);
+ }
+
+ delete canvas;
+}
+
+void tst_QDeclarativeListView::sections()
+{
+ QDeclarativeView *canvas = createView();
+
+ TestModel 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(QUrl::fromLocalFile(SRCDIR "/data/listview-sections.qml"));
+ qApp->processEvents();
+
+ QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list");
+ QVERIFY(listview != 0);
+
+ QDeclarativeItem *viewport = listview->viewport();
+ QVERIFY(viewport != 0);
+
+ // Confirm items positioned correctly
+ int itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QVERIFY(item);
+ QCOMPARE(item->y(), qreal(i*20 + ((i+4)/5) * 20));
+ }
+
+ // Remove section boundary
+ model.removeItem(5);
+
+ // New section header created
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", 5);
+ QVERIFY(item);
+ QCOMPARE(item->height(), 40.0);
+
+ model.insertItem(3, "New Item", "0");
+
+ // Section header moved
+ item = findItem<QDeclarativeItem>(viewport, "wrapper", 5);
+ QVERIFY(item);
+ QCOMPARE(item->height(), 20.0);
+
+ item = findItem<QDeclarativeItem>(viewport, "wrapper", 6);
+ QVERIFY(item);
+ QCOMPARE(item->height(), 40.0);
+
+ // insert item which will become a section header
+ model.insertItem(6, "Replace header", "1");
+
+ item = findItem<QDeclarativeItem>(viewport, "wrapper", 6);
+ QVERIFY(item);
+ QCOMPARE(item->height(), 40.0);
+
+ item = findItem<QDeclarativeItem>(viewport, "wrapper", 7);
+ QVERIFY(item);
+ QCOMPARE(item->height(), 20.0);
+
+ QCOMPARE(listview->currentSection(), QString("0"));
+
+ listview->setContentY(140);
+ QCOMPARE(listview->currentSection(), QString("1"));
+
+ listview->setContentY(20);
+ QCOMPARE(listview->currentSection(), QString("0"));
+
+ item = findItem<QDeclarativeItem>(viewport, "wrapper", 1);
+ QVERIFY(item);
+ QCOMPARE(item->height(), 20.0);
+
+ delete canvas;
+}
+
+void tst_QDeclarativeListView::currentIndex()
+{
+ TestModel model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), QString::number(i));
+
+ QDeclarativeView *canvas = new QDeclarativeView(0);
+ canvas->setFixedSize(240,320);
+
+ QDeclarativeContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("testWrap", QVariant(false));
+
+ QString filename(SRCDIR "/data/listview-initCurrent.qml");
+ canvas->setSource(QUrl::fromLocalFile(filename));
+
+ qApp->processEvents();
+
+ QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list");
+ QVERIFY(listview != 0);
+
+ QDeclarativeItem *viewport = listview->viewport();
+ QVERIFY(viewport != 0);
+
+ QTest::qWait(500);
+
+ // current item should be third item
+ QCOMPARE(listview->currentIndex(), 3);
+ QCOMPARE(listview->currentItem(), findItem<QDeclarativeItem>(viewport, "wrapper", 3));
+ QCOMPARE(listview->highlightItem()->y(), listview->currentItem()->y());
+
+ // no wrap
+ listview->setCurrentIndex(0);
+ QCOMPARE(listview->currentIndex(), 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);
+
+ QTest::qWait(1000);
+ QCOMPARE(listview->contentY(), 279.0);
+
+ listview->incrementCurrentIndex();
+ QCOMPARE(listview->currentIndex(), 0);
+
+ QTest::qWait(1000);
+ QCOMPARE(listview->contentY(), 0.0);
+
+ // Test keys
+ canvas->show();
+ qApp->processEvents();
+
+ QEvent wa(QEvent::WindowActivate);
+ QApplication::sendEvent(canvas, &wa);
+ QFocusEvent fe(QEvent::FocusIn);
+ QApplication::sendEvent(canvas, &fe);
+
+ QKeyEvent key(QEvent::KeyPress, Qt::Key_Down, Qt::NoModifier, "", false, 1);
+ QApplication::sendEvent(canvas, &key);
+ QVERIFY(key.isAccepted());
+ QCOMPARE(listview->currentIndex(), 1);
+
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Up, Qt::NoModifier, "", false, 1);
+ QApplication::sendEvent(canvas, &key);
+ QVERIFY(key.isAccepted());
+ QCOMPARE(listview->currentIndex(), 0);
+
+ // turn off auto highlight
+ listview->setHighlightFollowsCurrentItem(false);
+ QVERIFY(listview->highlightFollowsCurrentItem() == false);
+
+ QTest::qWait(500);
+ QVERIFY(listview->highlightItem());
+ qreal hlPos = listview->highlightItem()->y();
+
+ listview->setCurrentIndex(4);
+ QTest::qWait(500);
+ QCOMPARE(listview->highlightItem()->y(), hlPos);
+
+ delete canvas;
+}
+
+void tst_QDeclarativeListView::itemList()
+{
+ QDeclarativeView *canvas = createView();
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/itemlist.qml"));
+ qApp->processEvents();
+
+ QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "view");
+ QVERIFY(listview != 0);
+
+ QDeclarativeItem *viewport = listview->viewport();
+ QVERIFY(viewport != 0);
+
+ QDeclarativeVisualItemModel *model = canvas->rootObject()->findChild<QDeclarativeVisualItemModel*>("itemModel");
+ QVERIFY(model != 0);
+
+ QVERIFY(model->count() == 3);
+ QCOMPARE(listview->currentIndex(), 0);
+
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "item1");
+ QVERIFY(item);
+ QCOMPARE(item->x(), 0.0);
+
+ QDeclarativeText *text = findItem<QDeclarativeText>(viewport, "text1");
+ QVERIFY(text);
+ QCOMPARE(text->text(), QLatin1String("index: 0"));
+
+ listview->setCurrentIndex(2);
+ QTest::qWait(1000);
+
+ item = findItem<QDeclarativeItem>(viewport, "item3");
+ QVERIFY(item);
+ QCOMPARE(item->x(), 480.0);
+
+ text = findItem<QDeclarativeText>(viewport, "text3");
+ QVERIFY(text);
+ QCOMPARE(text->text(), QLatin1String("index: 2"));
+
+ delete canvas;
+}
+
+void tst_QDeclarativeListView::cacheBuffer()
+{
+ QDeclarativeView *canvas = createView();
+
+ TestModel 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(QUrl::fromLocalFile(SRCDIR "/data/listview.qml"));
+ qApp->processEvents();
+
+ QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list");
+ QVERIFY(listview != 0);
+
+ QDeclarativeItem *viewport = listview->viewport();
+ QVERIFY(viewport != 0);
+ QVERIFY(listview->delegate() != 0);
+ QVERIFY(listview->model() != 0);
+ QVERIFY(listview->highlight() != 0);
+
+ // Confirm items positioned correctly
+ int itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QVERIFY(item);
+ QVERIFY(item->y() == i*20);
+ }
+
+ testObject->setCacheBuffer(400);
+ QVERIFY(listview->cacheBuffer() == 400);
+
+ int newItemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ QVERIFY(newItemCount > itemCount);
+
+ // Confirm items positioned correctly
+ for (int i = 0; i < model.count() && i < newItemCount; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QVERIFY(item);
+ QVERIFY(item->y() == i*20);
+ }
+
+ delete canvas;
+}
+
+void tst_QDeclarativeListView::positionViewAtIndex()
+{
+ QDeclarativeView *canvas = createView();
+
+ TestModel model;
+ for (int i = 0; i < 40; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QDeclarativeContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testObject", testObject);
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listview.qml"));
+ qApp->processEvents();
+
+ QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list");
+ QVERIFY(listview != 0);
+
+ QDeclarativeItem *viewport = listview->viewport();
+ QVERIFY(viewport != 0);
+
+ // Confirm items positioned correctly
+ int itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QVERIFY(item);
+ QCOMPARE(item->y(), i*20.);
+ }
+
+ // Position on a currently visible item
+ listview->positionViewAtIndex(3);
+ QCOMPARE(listview->contentY(), 60.);
+
+ // Confirm items positioned correctly
+ itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ for (int i = 3; i < model.count() && i < itemCount-3-1; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QVERIFY(item);
+ QCOMPARE(item->y(), i*20.);
+ }
+
+ // Position on an item beyond the visible items
+ listview->positionViewAtIndex(22);
+ QCOMPARE(listview->contentY(), 440.);
+
+ // Confirm items positioned correctly
+ itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ for (int i = 22; i < model.count() && i < itemCount-22-1; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QVERIFY(item);
+ QCOMPARE(item->y(), i*20.);
+ }
+
+ // Position on an item that would leave empty space if positioned at the top
+ listview->positionViewAtIndex(28);
+ QCOMPARE(listview->contentY(), 480.);
+
+ // Confirm items positioned correctly
+ itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ for (int i = 24; i < model.count() && i < itemCount-24-1; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QVERIFY(item);
+ QCOMPARE(item->y(), i*20.);
+ }
+
+ // Position at the beginning again
+ listview->positionViewAtIndex(0);
+ QCOMPARE(listview->contentY(), 0.);
+
+ // Confirm items positioned correctly
+ itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount-1; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QVERIFY(item);
+ QCOMPARE(item->y(), i*20.);
+ }
+
+ delete canvas;
+}
+
+void tst_QDeclarativeListView::resetModel()
+{
+ QDeclarativeView *canvas = createView();
+
+ QStringList strings;
+ strings << "one" << "two" << "three";
+ QStringListModel model(strings);
+
+ QDeclarativeContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/displaylist.qml"));
+ qApp->processEvents();
+
+ QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list");
+ QVERIFY(listview != 0);
+
+ QDeclarativeItem *viewport = listview->viewport();
+ QVERIFY(viewport != 0);
+
+ QCOMPARE(listview->count(), model.rowCount());
+
+ for (int i = 0; i < model.rowCount(); ++i) {
+ QDeclarativeText *display = findItem<QDeclarativeText>(viewport, "displayText", i);
+ QVERIFY(display != 0);
+ QCOMPARE(display->text(), strings.at(i));
+ }
+
+ strings.clear();
+ strings << "four" << "five" << "six" << "seven";
+ model.setStringList(strings);
+
+ QCOMPARE(listview->count(), model.rowCount());
+
+ for (int i = 0; i < model.rowCount(); ++i) {
+ QDeclarativeText *display = findItem<QDeclarativeText>(viewport, "displayText", i);
+ QVERIFY(display != 0);
+ QCOMPARE(display->text(), strings.at(i));
+ }
+}
+
+void tst_QDeclarativeListView::qListModelInterface_items()
+{
+ items<TestModel>();
+}
+
+void tst_QDeclarativeListView::qAbstractItemModel_items()
+{
+ items<TestModel2>();
+}
+
+void tst_QDeclarativeListView::qListModelInterface_changed()
+{
+ changed<TestModel>();
+}
+
+void tst_QDeclarativeListView::qAbstractItemModel_changed()
+{
+ changed<TestModel2>();
+}
+
+void tst_QDeclarativeListView::qListModelInterface_inserted()
+{
+ inserted<TestModel>();
+}
+
+void tst_QDeclarativeListView::qAbstractItemModel_inserted()
+{
+ inserted<TestModel2>();
+}
+
+void tst_QDeclarativeListView::qListModelInterface_removed()
+{
+ removed<TestModel>(false);
+ removed<TestModel>(true);
+}
+
+void tst_QDeclarativeListView::qAbstractItemModel_removed()
+{
+ removed<TestModel2>(false);
+ removed<TestModel2>(true);
+}
+
+void tst_QDeclarativeListView::qListModelInterface_moved()
+{
+ moved<TestModel>();
+}
+
+void tst_QDeclarativeListView::qAbstractItemModel_moved()
+{
+ moved<TestModel2>();
+}
+
+void tst_QDeclarativeListView::qListModelInterface_clear()
+{
+ clear<TestModel>();
+}
+
+void tst_QDeclarativeListView::qAbstractItemModel_clear()
+{
+ clear<TestModel2>();
+}
+
+QDeclarativeView *tst_QDeclarativeListView::createView()
+{
+ QDeclarativeView *canvas = new QDeclarativeView(0);
+ canvas->setFixedSize(240,320);
+
+ return canvas;
+}
+
+/*
+ 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 *tst_QDeclarativeListView::findItem(QGraphicsObject *parent, const QString &objectName, int index)
+{
+ const QMetaObject &mo = T::staticMetaObject;
+ //qDebug() << parent->childItems().count() << "children";
+ for (int i = 0; i < parent->childItems().count(); ++i) {
+ QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(parent->childItems().at(i));
+ if(!item)
+ continue;
+ //qDebug() << "try" << item;
+ if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) {
+ if (index != -1) {
+ QDeclarativeExpression e(qmlContext(item), "index", item);
+ if (e.value().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*> tst_QDeclarativeListView::findItems(QGraphicsObject *parent, const QString &objectName)
+{
+ QList<T*> items;
+ const QMetaObject &mo = T::staticMetaObject;
+ //qDebug() << parent->childItems().count() << "children";
+ for (int i = 0; i < parent->childItems().count(); ++i) {
+ QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(parent->childItems().at(i));
+ if(!item)
+ continue;
+ //qDebug() << "try" << item;
+ if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName))
+ items.append(static_cast<T*>(item));
+ items += findItems<T>(item, objectName);
+ }
+
+ return items;
+}
+
+void tst_QDeclarativeListView::dumpTree(QDeclarativeItem *parent, int depth)
+{
+ static QString padding(" ");
+ for (int i = 0; i < parent->childItems().count(); ++i) {
+ QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(parent->childItems().at(i));
+ if(!item)
+ continue;
+ qDebug() << padding.left(depth*2) << item;
+ dumpTree(item, depth+1);
+ }
+}
+
+
+QTEST_MAIN(tst_QDeclarativeListView)
+
+#include "tst_qdeclarativelistview.moc"
diff --git a/tests/auto/declarative/qdeclarativeloader/data/GraphicsWidget250x250.qml b/tests/auto/declarative/qdeclarativeloader/data/GraphicsWidget250x250.qml
new file mode 100644
index 0000000..4ebf366
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeloader/data/GraphicsWidget250x250.qml
@@ -0,0 +1,6 @@
+import Qt 4.6
+import Qt.widgets 4.6
+
+QGraphicsWidget {
+ size: "250x250"
+}
diff --git a/tests/auto/declarative/qmlgraphicsloader/data/NoResize.qml b/tests/auto/declarative/qdeclarativeloader/data/NoResize.qml
index cfbb55a..cfbb55a 100644
--- a/tests/auto/declarative/qmlgraphicsloader/data/NoResize.qml
+++ b/tests/auto/declarative/qdeclarativeloader/data/NoResize.qml
diff --git a/tests/auto/declarative/qmlgraphicsloader/data/NoResizeGraphicsWidget.qml b/tests/auto/declarative/qdeclarativeloader/data/NoResizeGraphicsWidget.qml
index 5eab965..5eab965 100644
--- a/tests/auto/declarative/qmlgraphicsloader/data/NoResizeGraphicsWidget.qml
+++ b/tests/auto/declarative/qdeclarativeloader/data/NoResizeGraphicsWidget.qml
diff --git a/tests/auto/declarative/qmlgraphicsloader/data/Rect120x60.qml b/tests/auto/declarative/qdeclarativeloader/data/Rect120x60.qml
index aa4b0c2..aa4b0c2 100644
--- a/tests/auto/declarative/qmlgraphicsloader/data/Rect120x60.qml
+++ b/tests/auto/declarative/qdeclarativeloader/data/Rect120x60.qml
diff --git a/tests/auto/declarative/qmlgraphicsloader/data/SetSourceComponent.qml b/tests/auto/declarative/qdeclarativeloader/data/SetSourceComponent.qml
index 1db56c4..1db56c4 100644
--- a/tests/auto/declarative/qmlgraphicsloader/data/SetSourceComponent.qml
+++ b/tests/auto/declarative/qdeclarativeloader/data/SetSourceComponent.qml
diff --git a/tests/auto/declarative/qmlgraphicsloader/data/SizeGraphicsWidgetToLoader.qml b/tests/auto/declarative/qdeclarativeloader/data/SizeGraphicsWidgetToLoader.qml
index 568a136..568a136 100644
--- a/tests/auto/declarative/qmlgraphicsloader/data/SizeGraphicsWidgetToLoader.qml
+++ b/tests/auto/declarative/qdeclarativeloader/data/SizeGraphicsWidgetToLoader.qml
diff --git a/tests/auto/declarative/qmlgraphicsloader/data/SizeLoaderToGraphicsWidget.qml b/tests/auto/declarative/qdeclarativeloader/data/SizeLoaderToGraphicsWidget.qml
index a710803..a710803 100644
--- a/tests/auto/declarative/qmlgraphicsloader/data/SizeLoaderToGraphicsWidget.qml
+++ b/tests/auto/declarative/qdeclarativeloader/data/SizeLoaderToGraphicsWidget.qml
diff --git a/tests/auto/declarative/qmlgraphicsloader/data/SizeToItem.qml b/tests/auto/declarative/qdeclarativeloader/data/SizeToItem.qml
index b52fa03..b52fa03 100644
--- a/tests/auto/declarative/qmlgraphicsloader/data/SizeToItem.qml
+++ b/tests/auto/declarative/qdeclarativeloader/data/SizeToItem.qml
diff --git a/tests/auto/declarative/qmlgraphicsloader/data/SizeToLoader.qml b/tests/auto/declarative/qdeclarativeloader/data/SizeToLoader.qml
index 1a107e1..1a107e1 100644
--- a/tests/auto/declarative/qmlgraphicsloader/data/SizeToLoader.qml
+++ b/tests/auto/declarative/qdeclarativeloader/data/SizeToLoader.qml
diff --git a/tests/auto/declarative/qdeclarativeloader/qdeclarativeloader.pro b/tests/auto/declarative/qdeclarativeloader/qdeclarativeloader.pro
new file mode 100644
index 0000000..8ff2be4
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeloader/qdeclarativeloader.pro
@@ -0,0 +1,11 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative gui network
+macx:CONFIG -= app_bundle
+
+INCLUDEPATH += ../shared/
+HEADERS += ../shared/testhttpserver.h
+SOURCES += tst_qdeclarativeloader.cpp \
+ ../shared/testhttpserver.cpp
+
+DEFINES += SRCDIR=\\\"$$PWD\\\"
+
diff --git a/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp b/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp
new file mode 100644
index 0000000..61b2800
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp
@@ -0,0 +1,464 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QtGui/QGraphicsWidget>
+#include <QtGui/QGraphicsScene>
+
+#include <QSignalSpy>
+#include <QtDeclarative/qdeclarativeengine.h>
+#include <QtDeclarative/qdeclarativecomponent.h>
+#include <private/qdeclarativeloader_p.h>
+#include "testhttpserver.h"
+
+#define SERVER_PORT 14445
+
+inline QUrl TEST_FILE(const QString &filename)
+{
+ return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename);
+}
+
+#define TRY_WAIT(expr) \
+ do { \
+ for (int ii = 0; ii < 6; ++ii) { \
+ if ((expr)) break; \
+ QTest::qWait(50); \
+ } \
+ QVERIFY((expr)); \
+ } while (false)
+
+class tst_QDeclarativeLoader : public QObject
+
+{
+ Q_OBJECT
+public:
+ tst_QDeclarativeLoader();
+
+private slots:
+ void url();
+ void invalidUrl();
+ void component();
+ void clear();
+ void urlToComponent();
+ void componentToUrl();
+ void sizeLoaderToItem();
+ void sizeItemToLoader();
+ void noResize();
+ void sizeLoaderToGraphicsWidget();
+ void sizeGraphicsWidgetToLoader();
+ void noResizeGraphicsWidget();
+ void networkRequestUrl();
+ void failNetworkRequest();
+// void networkComponent();
+
+private:
+ QDeclarativeEngine engine;
+};
+
+
+tst_QDeclarativeLoader::tst_QDeclarativeLoader()
+{
+}
+
+void tst_QDeclarativeLoader::url()
+{
+ QDeclarativeComponent component(&engine);
+ component.setData(QByteArray("import Qt 4.6\nLoader { source: \"Rect120x60.qml\" }"), TEST_FILE(""));
+ QDeclarativeLoader *loader = qobject_cast<QDeclarativeLoader*>(component.create());
+ QVERIFY(loader != 0);
+ QVERIFY(loader->item());
+ QVERIFY(loader->source() == QUrl::fromLocalFile(SRCDIR "/data/Rect120x60.qml"));
+ QCOMPARE(loader->progress(), 1.0);
+ QCOMPARE(loader->status(), QDeclarativeLoader::Ready);
+ QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 1);
+
+ delete loader;
+}
+
+void tst_QDeclarativeLoader::component()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("/SetSourceComponent.qml"));
+ QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(component.create());
+ QVERIFY(item);
+
+ QDeclarativeLoader *loader = qobject_cast<QDeclarativeLoader*>(item->QGraphicsObject::children().at(1));
+ QVERIFY(loader);
+ QVERIFY(loader->item());
+ QCOMPARE(loader->progress(), 1.0);
+ QCOMPARE(loader->status(), QDeclarativeLoader::Ready);
+ QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 1);
+
+ delete loader;
+}
+
+void tst_QDeclarativeLoader::invalidUrl()
+{
+ QTest::ignoreMessage(QtWarningMsg, QString("(:-1: File error for URL " + QUrl::fromLocalFile(SRCDIR "/data/IDontExist.qml").toString() + ") ").toUtf8().constData());
+
+ QDeclarativeComponent component(&engine);
+ component.setData(QByteArray("import Qt 4.6\nLoader { source: \"IDontExist.qml\" }"), TEST_FILE(""));
+ QDeclarativeLoader *loader = qobject_cast<QDeclarativeLoader*>(component.create());
+ QVERIFY(loader != 0);
+ QVERIFY(loader->item() == 0);
+ QCOMPARE(loader->progress(), 1.0);
+ QCOMPARE(loader->status(), QDeclarativeLoader::Error);
+ QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 0);
+
+ delete loader;
+}
+
+void tst_QDeclarativeLoader::clear()
+{
+ {
+ QDeclarativeComponent component(&engine);
+ component.setData(QByteArray(
+ "import Qt 4.6\n"
+ " Loader { id: loader\n"
+ " source: 'Rect120x60.qml'\n"
+ " Timer { interval: 200; running: true; onTriggered: loader.source = '' }\n"
+ " }")
+ , TEST_FILE(""));
+ QDeclarativeLoader *loader = qobject_cast<QDeclarativeLoader*>(component.create());
+ QVERIFY(loader != 0);
+ QVERIFY(loader->item());
+ QCOMPARE(loader->progress(), 1.0);
+ QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 1);
+
+ QTest::qWait(500);
+
+ QVERIFY(loader->item() == 0);
+ QCOMPARE(loader->progress(), 0.0);
+ QCOMPARE(loader->status(), QDeclarativeLoader::Null);
+ QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 0);
+
+ delete loader;
+ }
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("/SetSourceComponent.qml"));
+ QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(component.create());
+ QVERIFY(item);
+
+ QDeclarativeLoader *loader = qobject_cast<QDeclarativeLoader*>(item->QGraphicsObject::children().at(1));
+ QVERIFY(loader);
+ QVERIFY(loader->item());
+ QCOMPARE(loader->progress(), 1.0);
+ QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 1);
+
+ loader->setSourceComponent(0);
+
+ QVERIFY(loader->item() == 0);
+ QCOMPARE(loader->progress(), 0.0);
+ QCOMPARE(loader->status(), QDeclarativeLoader::Null);
+ QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 0);
+
+ delete loader;
+ }
+}
+
+void tst_QDeclarativeLoader::urlToComponent()
+{
+ QDeclarativeComponent component(&engine);
+ component.setData(QByteArray("import Qt 4.6\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"
+ "}" )
+ , TEST_FILE(""));
+ QDeclarativeLoader *loader = qobject_cast<QDeclarativeLoader*>(component.create());
+ QTest::qWait(500);
+ QVERIFY(loader != 0);
+ QVERIFY(loader->item());
+ QCOMPARE(loader->progress(), 1.0);
+ QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 1);
+ QCOMPARE(loader->width(), 10.0);
+ QCOMPARE(loader->height(), 10.0);
+
+ delete loader;
+}
+
+void tst_QDeclarativeLoader::componentToUrl()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("/SetSourceComponent.qml"));
+ QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(component.create());
+ QVERIFY(item);
+
+ QDeclarativeLoader *loader = qobject_cast<QDeclarativeLoader*>(item->QGraphicsObject::children().at(1));
+ QVERIFY(loader);
+ QVERIFY(loader->item());
+ QCOMPARE(loader->progress(), 1.0);
+ QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 1);
+
+ loader->setSource(TEST_FILE("/Rect120x60.qml"));
+ QVERIFY(loader->item());
+ QCOMPARE(loader->progress(), 1.0);
+ QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 1);
+ QCOMPARE(loader->width(), 120.0);
+ QCOMPARE(loader->height(), 60.0);
+
+ delete loader;
+}
+
+void tst_QDeclarativeLoader::sizeLoaderToItem()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("/SizeToItem.qml"));
+ QDeclarativeLoader *loader = qobject_cast<QDeclarativeLoader*>(component.create());
+ QVERIFY(loader != 0);
+ QVERIFY(loader->resizeMode() == QDeclarativeLoader::SizeLoaderToItem);
+ QCOMPARE(loader->width(), 120.0);
+ QCOMPARE(loader->height(), 60.0);
+
+ // Check resize
+ QDeclarativeItem *rect = qobject_cast<QDeclarativeItem*>(loader->item());
+ QVERIFY(rect);
+ rect->setWidth(150);
+ rect->setHeight(45);
+ QCOMPARE(loader->width(), 150.0);
+ QCOMPARE(loader->height(), 45.0);
+
+ // Switch mode
+ loader->setResizeMode(QDeclarativeLoader::SizeItemToLoader);
+ loader->setWidth(180);
+ loader->setHeight(30);
+ QCOMPARE(rect->width(), 180.0);
+ QCOMPARE(rect->height(), 30.0);
+
+ // notify
+ QSignalSpy spy(loader, SIGNAL(resizeModeChanged()));
+ loader->setResizeMode(QDeclarativeLoader::NoResize);
+ QCOMPARE(spy.count(),1);
+ loader->setResizeMode(QDeclarativeLoader::NoResize);
+ QCOMPARE(spy.count(),1);
+}
+
+void tst_QDeclarativeLoader::sizeItemToLoader()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("/SizeToLoader.qml"));
+ QDeclarativeLoader *loader = qobject_cast<QDeclarativeLoader*>(component.create());
+ QVERIFY(loader != 0);
+ QVERIFY(loader->resizeMode() == QDeclarativeLoader::SizeItemToLoader);
+ QCOMPARE(loader->width(), 200.0);
+ QCOMPARE(loader->height(), 80.0);
+
+ QDeclarativeItem *rect = qobject_cast<QDeclarativeItem*>(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->setResizeMode(QDeclarativeLoader::SizeLoaderToItem);
+ rect->setWidth(160);
+ rect->setHeight(45);
+ QCOMPARE(loader->width(), 160.0);
+ QCOMPARE(loader->height(), 45.0);
+}
+
+void tst_QDeclarativeLoader::noResize()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("/NoResize.qml"));
+ QDeclarativeLoader *loader = qobject_cast<QDeclarativeLoader*>(component.create());
+ QVERIFY(loader != 0);
+ QCOMPARE(loader->width(), 200.0);
+ QCOMPARE(loader->height(), 80.0);
+
+ QDeclarativeItem *rect = qobject_cast<QDeclarativeItem*>(loader->item());
+ QVERIFY(rect);
+ QCOMPARE(rect->width(), 120.0);
+ QCOMPARE(rect->height(), 60.0);
+}
+
+void tst_QDeclarativeLoader::sizeLoaderToGraphicsWidget()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("/SizeLoaderToGraphicsWidget.qml"));
+ QDeclarativeLoader *loader = qobject_cast<QDeclarativeLoader*>(component.create());
+ QGraphicsScene scene;
+ scene.addItem(loader);
+
+ QVERIFY(loader != 0);
+ QVERIFY(loader->resizeMode() == QDeclarativeLoader::SizeLoaderToItem);
+ QCOMPARE(loader->width(), 250.0);
+ QCOMPARE(loader->height(), 250.0);
+
+ // Check resize
+ QGraphicsWidget *widget = qobject_cast<QGraphicsWidget*>(loader->item());
+ QVERIFY(widget);
+ widget->resize(QSizeF(150,45));
+ QCOMPARE(loader->width(), 150.0);
+ QCOMPARE(loader->height(), 45.0);
+
+ // Switch mode
+ loader->setResizeMode(QDeclarativeLoader::SizeItemToLoader);
+ loader->setWidth(180);
+ loader->setHeight(30);
+ QCOMPARE(widget->size().width(), 180.0);
+ QCOMPARE(widget->size().height(), 30.0);
+}
+
+void tst_QDeclarativeLoader::sizeGraphicsWidgetToLoader()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("/SizeGraphicsWidgetToLoader.qml"));
+ QDeclarativeLoader *loader = qobject_cast<QDeclarativeLoader*>(component.create());
+ QGraphicsScene scene;
+ scene.addItem(loader);
+
+ QVERIFY(loader != 0);
+ QVERIFY(loader->resizeMode() == QDeclarativeLoader::SizeItemToLoader);
+ QCOMPARE(loader->width(), 200.0);
+ QCOMPARE(loader->height(), 80.0);
+
+ QGraphicsWidget *widget = qobject_cast<QGraphicsWidget*>(loader->item());
+ QVERIFY(widget);
+ QCOMPARE(widget->size().width(), 200.0);
+ QCOMPARE(widget->size().height(), 80.0);
+
+ // Check resize
+ loader->setWidth(180);
+ loader->setHeight(30);
+ QCOMPARE(widget->size().width(), 180.0);
+ QCOMPARE(widget->size().height(), 30.0);
+
+ // Switch mode
+ loader->setResizeMode(QDeclarativeLoader::SizeLoaderToItem);
+ widget->resize(QSizeF(160,45));
+ QCOMPARE(loader->width(), 160.0);
+ QCOMPARE(loader->height(), 45.0);
+}
+
+void tst_QDeclarativeLoader::noResizeGraphicsWidget()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("/NoResizeGraphicsWidget.qml"));
+ QDeclarativeLoader *loader = qobject_cast<QDeclarativeLoader*>(component.create());
+ QGraphicsScene scene;
+ scene.addItem(loader);
+
+ QVERIFY(loader != 0);
+ QCOMPARE(loader->width(), 200.0);
+ QCOMPARE(loader->height(), 80.0);
+
+ QGraphicsWidget *widget = qobject_cast<QGraphicsWidget*>(loader->item());
+ QVERIFY(widget);
+ QCOMPARE(widget->size().width(), 250.0);
+ QCOMPARE(widget->size().height(), 250.0);
+}
+
+void tst_QDeclarativeLoader::networkRequestUrl()
+{
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ server.serveDirectory(SRCDIR "/data");
+
+ QDeclarativeComponent component(&engine);
+ component.setData(QByteArray("import Qt 4.6\nLoader { source: \"http://127.0.0.1:14445/Rect120x60.qml\" }"), TEST_FILE(""));
+ QDeclarativeLoader *loader = qobject_cast<QDeclarativeLoader*>(component.create());
+ QVERIFY(loader != 0);
+
+ TRY_WAIT(loader->status() == QDeclarativeLoader::Ready);
+
+ QVERIFY(loader->item());
+ QCOMPARE(loader->progress(), 1.0);
+ QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 1);
+
+ delete loader;
+}
+
+/* XXX Component waits until all dependencies are loaded. Is this actually possible?
+void tst_QDeclarativeLoader::networkComponent()
+{
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ server.serveDirectory("slowdata", TestHTTPServer::Delay);
+
+ QDeclarativeComponent component(&engine);
+ component.setData(QByteArray(
+ "import Qt 4.6\n"
+ "import \"http://127.0.0.1:14445/\" as NW\n"
+ "Item {\n"
+ " Component { id: comp; NW.SlowRect {} }\n"
+ " Loader { sourceComponent: comp } }")
+ , TEST_FILE(""));
+
+ QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(component.create());
+ QVERIFY(item);
+
+ QDeclarativeLoader *loader = qobject_cast<QDeclarativeLoader*>(item->QGraphicsObject::children().at(1));
+ QVERIFY(loader);
+ TRY_WAIT(loader->status() == QDeclarativeLoader::Ready);
+
+ QVERIFY(loader->item());
+ QCOMPARE(loader->progress(), 1.0);
+ QCOMPARE(loader->status(), QDeclarativeLoader::Ready);
+ QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 1);
+
+ delete loader;
+}
+*/
+
+void tst_QDeclarativeLoader::failNetworkRequest()
+{
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ server.serveDirectory(SRCDIR "/data");
+
+ QTest::ignoreMessage(QtWarningMsg, "(:-1: Network error for URL http://127.0.0.1:14445/IDontExist.qml) ");
+
+ QDeclarativeComponent component(&engine);
+ component.setData(QByteArray("import Qt 4.6\nLoader { source: \"http://127.0.0.1:14445/IDontExist.qml\" }"), TEST_FILE(""));
+ QDeclarativeLoader *loader = qobject_cast<QDeclarativeLoader*>(component.create());
+ QVERIFY(loader != 0);
+
+ TRY_WAIT(loader->status() == QDeclarativeLoader::Error);
+
+ QVERIFY(loader->item() == 0);
+ QCOMPARE(loader->progress(), 0.0);
+ QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 0);
+
+ delete loader;
+}
+
+QTEST_MAIN(tst_QDeclarativeLoader)
+
+#include "tst_qdeclarativeloader.moc"
diff --git a/tests/auto/declarative/qdeclarativemetatype/qdeclarativemetatype.pro b/tests/auto/declarative/qdeclarativemetatype/qdeclarativemetatype.pro
new file mode 100644
index 0000000..2f7ff82
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativemetatype/qdeclarativemetatype.pro
@@ -0,0 +1,6 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative
+SOURCES += tst_qdeclarativemetatype.cpp
+macx:CONFIG -= app_bundle
+
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qdeclarativemetatype/tst_qdeclarativemetatype.cpp b/tests/auto/declarative/qdeclarativemetatype/tst_qdeclarativemetatype.cpp
new file mode 100644
index 0000000..818f108
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativemetatype/tst_qdeclarativemetatype.cpp
@@ -0,0 +1,378 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+#include <QLocale>
+#include <QPixmap>
+#include <QBitmap>
+#include <QPen>
+#include <QTextLength>
+#include <QMatrix4x4>
+#include <QVector2D>
+#include <QVector3D>
+#include <QVector4D>
+#include <QQuaternion>
+#include <qdeclarative.h>
+
+#include <private/qdeclarativemetatype_p.h>
+
+class tst_qdeclarativemetatype : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qdeclarativemetatype() {}
+
+private slots:
+ void initTestCase();
+
+ void copy();
+
+ 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
+ Q_CLASSINFO("DefaultProperty", "foo"); // Missing default property
+};
+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);
+
+
+#define COPY_TEST(cpptype, metatype, value, defaultvalue) \
+{ \
+ cpptype v = (value); cpptype v2 = (value); \
+ QVERIFY(QDeclarativeMetaType::copy(QMetaType:: metatype, &v, 0)); \
+ QVERIFY(v == (defaultvalue)); \
+ QVERIFY(QDeclarativeMetaType::copy(QMetaType:: metatype, &v, &v2)); \
+ QVERIFY(v == (value)); \
+}
+
+#define QT_COPY_TEST(type, value) \
+{ \
+ type v = (value); type v2 = (value); \
+ QVERIFY(QDeclarativeMetaType::copy(QMetaType:: type, &v, 0)); \
+ QVERIFY(v == (type ())); \
+ QVERIFY(QDeclarativeMetaType::copy(QMetaType:: type, &v, &v2)); \
+ QVERIFY(v == (value)); \
+}
+
+void tst_qdeclarativemetatype::initTestCase()
+{
+ QML_REGISTER_TYPE(Test, 1, 0, TestType, TestType);
+ QML_REGISTER_TYPE(Test, 1, 0, ParserStatusTestType, ParserStatusTestType);
+ QML_REGISTER_TYPE(Test, 1, 0, ValueSourceTestType, ValueSourceTestType);
+ QML_REGISTER_TYPE(Test, 1, 0, ValueInterceptorTestType, ValueInterceptorTestType);
+}
+
+void tst_qdeclarativemetatype::copy()
+{
+ QVERIFY(QDeclarativeMetaType::copy(QMetaType::Void, 0, 0));
+
+ COPY_TEST(bool, Bool, true, false);
+ COPY_TEST(int, Int, 10, 0);
+ COPY_TEST(unsigned int, UInt, 10, 0);
+ COPY_TEST(long long, LongLong, 10, 0);
+ COPY_TEST(unsigned long long, ULongLong, 10, 0);
+ COPY_TEST(double, Double, 19.2, 0);
+
+ QT_COPY_TEST(QChar, QChar('a'));
+
+ QVariantMap variantMap;
+ variantMap.insert("Hello World!", QVariant(10));
+ QT_COPY_TEST(QVariantMap, variantMap);
+
+ QT_COPY_TEST(QVariantList, QVariantList() << QVariant(19.2));
+ QT_COPY_TEST(QString, QString("QML Rocks!"));
+ QT_COPY_TEST(QStringList, QStringList() << "QML" << "Rocks");
+ QT_COPY_TEST(QByteArray, QByteArray("0x1102DDD"));
+ QT_COPY_TEST(QBitArray, QBitArray(102, true));
+ QDate cd = QDate::currentDate();
+ QT_COPY_TEST(QDate, cd);
+ QTime ct = QTime::currentTime();
+ QT_COPY_TEST(QTime, ct);
+ QDateTime cdt = QDateTime::currentDateTime();
+ QT_COPY_TEST(QDateTime, cdt);
+ QT_COPY_TEST(QUrl, QUrl("http://www.nokia.com"));
+ QT_COPY_TEST(QLocale, QLocale(QLocale::English, QLocale::Australia));
+ QT_COPY_TEST(QRect, QRect(-10, 10, 102, 99));
+ QT_COPY_TEST(QRectF, QRectF(-10.2, 1.2, 102, 99.6));
+ QT_COPY_TEST(QSize, QSize(100, 2));
+ QT_COPY_TEST(QSizeF, QSizeF(20.2, -100234.2));
+ QT_COPY_TEST(QLine, QLine(0, 0, 100, 100));
+ QT_COPY_TEST(QLineF, QLineF(-10.2, 0, 103, 1));
+ QT_COPY_TEST(QPoint, QPoint(-1912, 1613));
+ QT_COPY_TEST(QPointF, QPointF(-908.1, 1612));
+ QT_COPY_TEST(QRegExp, QRegExp("(\\d+)(?:\\s*)(cm|inch)"));
+
+ QVariantHash variantHash;
+ variantHash.insert("Hello World!", QVariant(19));
+ QT_COPY_TEST(QVariantHash, variantHash);
+
+#ifdef QT3_SUPPORT
+ QT_COPY_TEST(QColorGroup, QColorGroup(Qt::red, Qt::red, Qt::red, Qt::red, Qt::red, Qt::red, Qt::red));
+#endif
+
+ QT_COPY_TEST(QFont, QFont("Helvetica", 1024));
+
+ {
+ QPixmap v = QPixmap(100, 100); QPixmap v2 = QPixmap(100, 100);
+ QVERIFY(QDeclarativeMetaType::copy(QMetaType::QPixmap, &v, 0));
+ QVERIFY(v.size() == QPixmap().size());
+ QVERIFY(QDeclarativeMetaType::copy(QMetaType::QPixmap , &v, &v2));
+ QVERIFY(v.size() == QPixmap(100,100).size());
+ }
+
+ QT_COPY_TEST(QBrush, QBrush(Qt::blue));
+ QT_COPY_TEST(QColor, QColor("lightsteelblue"));
+ QT_COPY_TEST(QPalette, QPalette(Qt::green));
+
+ {
+ QPixmap icon(100, 100);
+
+ QIcon v = QIcon(icon); QIcon v2 = QIcon(icon);
+ QVERIFY(QDeclarativeMetaType::copy(QMetaType::QIcon, &v, 0));
+ QVERIFY(v.isNull() == QIcon().isNull());
+ QVERIFY(QDeclarativeMetaType::copy(QMetaType::QIcon , &v, &v2));
+ QVERIFY(v.isNull() == QIcon(icon).isNull());
+ }
+
+ {
+ QImage v = QImage(100, 100, QImage::Format_RGB32);
+ QImage v2 = QImage(100, 100, QImage::Format_RGB32);
+ QVERIFY(QDeclarativeMetaType::copy(QMetaType::QImage, &v, 0));
+ QVERIFY(v.size() == QImage().size());
+ QVERIFY(QDeclarativeMetaType::copy(QMetaType::QImage , &v, &v2));
+ QVERIFY(v.size() == QImage(100,100, QImage::Format_RGB32).size());
+ }
+
+ QT_COPY_TEST(QPolygon, QPolygon(QRect(100, 100, 200, 103)));
+ QT_COPY_TEST(QRegion, QRegion(QRect(0, 10, 99, 87)));
+
+ {
+ QBitmap v = QBitmap(100, 100); QBitmap v2 = QBitmap(100, 100);
+ QVERIFY(QDeclarativeMetaType::copy(QMetaType::QBitmap, &v, 0));
+ QVERIFY(v.size() == QBitmap().size());
+ QVERIFY(QDeclarativeMetaType::copy(QMetaType::QBitmap , &v, &v2));
+ QVERIFY(v.size() == QBitmap(100,100).size());
+ }
+
+ {
+ QCursor v = QCursor(Qt::SizeFDiagCursor); QCursor v2 = QCursor(Qt::SizeFDiagCursor);
+ QVERIFY(QDeclarativeMetaType::copy(QMetaType::QCursor, &v, 0));
+ QVERIFY(v.shape() == QCursor().shape());
+ QVERIFY(QDeclarativeMetaType::copy(QMetaType::QCursor , &v, &v2));
+ QVERIFY(v.shape() == QCursor(Qt::SizeFDiagCursor).shape());
+ }
+
+ QT_COPY_TEST(QSizePolicy, QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Maximum));
+ QT_COPY_TEST(QKeySequence, QKeySequence("Ctrl+O"));
+ QT_COPY_TEST(QPen, QPen(Qt::red));
+ QT_COPY_TEST(QTextLength, QTextLength(QTextLength::FixedLength, 10.2));
+ QT_COPY_TEST(QTextFormat, QTextFormat(QTextFormat::ListFormat));
+ QT_COPY_TEST(QMatrix, QMatrix().translate(10, 10));
+ QT_COPY_TEST(QTransform, QTransform().translate(10, 10));
+ QT_COPY_TEST(QMatrix4x4, QMatrix4x4(1,0,2,3,0,1,0,0,9,0,1,0,0,0,10,1));
+ QT_COPY_TEST(QVector2D, QVector2D(10.2, 1));
+ QT_COPY_TEST(QVector3D, QVector3D(10.2, 1, -2));
+ QT_COPY_TEST(QVector4D, QVector4D(10.2, 1, -2, 1.2));
+ QT_COPY_TEST(QQuaternion, QQuaternion(1.0, 10.2, 1, -2));
+
+ int voidValue;
+ COPY_TEST(void *, VoidStar, (void *)&voidValue, (void *)0);
+ COPY_TEST(long, Long, 10, 0);
+ COPY_TEST(short, Short, 10, 0);
+ COPY_TEST(char, Char, 'a', 0);
+ COPY_TEST(unsigned long, ULong, 10, 0);
+ COPY_TEST(unsigned short, UShort, 10, 0);
+ COPY_TEST(unsigned char, UChar, 'a', 0);
+ COPY_TEST(float, Float, 10.5, 0);
+
+ QObject objectValue;
+ QWidget widgetValue;
+ COPY_TEST(QObject *, QObjectStar, &objectValue, 0);
+ COPY_TEST(QWidget *, QWidgetStar, &widgetValue, 0);
+ COPY_TEST(qreal, QReal, 10.2, 0);
+
+ {
+ QVariant tv = QVariant::fromValue(QVariant(10));
+ QVariant v(tv); QVariant v2(tv);
+ QVERIFY(QDeclarativeMetaType::copy(qMetaTypeId<QVariant>(), &v, 0));
+ QVERIFY(v == QVariant());
+ QVERIFY(QDeclarativeMetaType::copy(qMetaTypeId<QVariant>(), &v, &v2));
+ QVERIFY(v == tv);
+ }
+
+ {
+ TestType t; QVariant tv = QVariant::fromValue(&t);
+
+ QVariant v(tv); QVariant v2(tv);
+ QVERIFY(QDeclarativeMetaType::copy(qMetaTypeId<TestType *>(), &v, 0));
+ QVERIFY(v == QVariant::fromValue((TestType *)0));
+ QVERIFY(QDeclarativeMetaType::copy(qMetaTypeId<TestType *>(), &v, &v2));
+ QVERIFY(v == tv);
+ }
+}
+
+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, &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, &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, &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/com/nokia/AutoTestQmlPluginType/qmldir b/tests/auto/declarative/qdeclarativemoduleplugin/com/nokia/AutoTestQmlPluginType/qmldir
new file mode 100644
index 0000000..0a8b5d4
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativemoduleplugin/com/nokia/AutoTestQmlPluginType/qmldir
@@ -0,0 +1 @@
+plugin plugin
diff --git a/tests/auto/declarative/qmlmoduleplugin/plugin.qml b/tests/auto/declarative/qdeclarativemoduleplugin/plugin.qml
index f29ae24..f29ae24 100644
--- a/tests/auto/declarative/qmlmoduleplugin/plugin.qml
+++ b/tests/auto/declarative/qdeclarativemoduleplugin/plugin.qml
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/plugin/plugin.cpp b/tests/auto/declarative/qdeclarativemoduleplugin/plugin/plugin.cpp
new file mode 100644
index 0000000..fd94cc6
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativemoduleplugin/plugin/plugin.cpp
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <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;
+};
+
+QML_DECLARE_TYPE(MyPluginType);
+
+
+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
new file mode 100644
index 0000000..035cb7d
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativemoduleplugin/plugin/plugin.pro
@@ -0,0 +1,6 @@
+TEMPLATE = lib
+CONFIG += plugin
+SOURCES = plugin.cpp
+QT = core declarative
+DESTDIR = ../com/nokia/AutoTestQmlPluginType
+
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/qdeclarativemoduleplugin.pro b/tests/auto/declarative/qdeclarativemoduleplugin/qdeclarativemoduleplugin.pro
new file mode 100644
index 0000000..96f4454
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativemoduleplugin/qdeclarativemoduleplugin.pro
@@ -0,0 +1,7 @@
+QT = core
+TEMPLATE = subdirs
+SUBDIRS = plugin
+tst_qdeclarativemoduleplugin_pro.depends += plugin
+SUBDIRS += tst_qdeclarativemoduleplugin.pro
+
+
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp b/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp
new file mode 100644
index 0000000..f3caa7f
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp
@@ -0,0 +1,117 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <qdir.h>
+#include <QtDeclarative/qdeclarativeengine.h>
+#include <QtDeclarative/qdeclarativecomponent.h>
+#include <QDebug>
+
+class tst_qdeclarativemoduleplugin : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qdeclarativemoduleplugin() {
+ QCoreApplication::addLibraryPath(QLatin1String(SRCDIR) + QDir::separator() + QLatin1String("plugin"));
+qDebug() << QLatin1String(SRCDIR) + QDir::separator() + QLatin1String("plugin");
+ }
+
+private slots:
+ void importsPlugin();
+};
+
+#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 { \
+ QFile file(QLatin1String("data/") + QLatin1String(errorfile)); \
+ QVERIFY(file.open(QIODevice::ReadOnly)); \
+ 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(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)
+{
+ QFileInfo fileInfo(__FILE__);
+ return QUrl::fromLocalFile(fileInfo.absoluteDir().filePath(filename));
+}
+
+
+void tst_qdeclarativemoduleplugin::importsPlugin()
+{
+ QDeclarativeEngine engine;
+ QTest::ignoreMessage(QtWarningMsg, "plugin created");
+ QTest::ignoreMessage(QtWarningMsg, "import worked");
+ QDeclarativeComponent component(&engine, TEST_FILE("plugin.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QCOMPARE(object->property("value").toInt(),123);
+}
+
+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
new file mode 100644
index 0000000..d895ed0
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.pro
@@ -0,0 +1,5 @@
+load(qttest_p4)
+SOURCES = tst_qdeclarativemoduleplugin.cpp
+QT += declarative
+CONFIG -= app_bundle
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmlgraphicsmousearea/data/dragproperties.qml b/tests/auto/declarative/qdeclarativemousearea/data/dragproperties.qml
index 4cd78da..4cd78da 100644
--- a/tests/auto/declarative/qmlgraphicsmousearea/data/dragproperties.qml
+++ b/tests/auto/declarative/qdeclarativemousearea/data/dragproperties.qml
diff --git a/tests/auto/declarative/qdeclarativemousearea/qdeclarativemousearea.pro b/tests/auto/declarative/qdeclarativemousearea/qdeclarativemousearea.pro
new file mode 100644
index 0000000..d01955b
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativemousearea/qdeclarativemousearea.pro
@@ -0,0 +1,9 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative gui network
+macx:CONFIG -= app_bundle
+
+HEADERS += ../shared/testhttpserver.h
+SOURCES += tst_qdeclarativemousearea.cpp ../shared/testhttpserver.cpp
+
+# Define SRCDIR equal to test's source directory
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp b/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp
new file mode 100644
index 0000000..769cf32
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp
@@ -0,0 +1,138 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+#include <QtTest/QSignalSpy>
+#include <private/qdeclarativemousearea_p.h>
+#include <QtDeclarative/qdeclarativeview.h>
+
+class tst_QDeclarativeMouseArea: public QObject
+{
+ Q_OBJECT
+private slots:
+ void dragProperties();
+private:
+ QDeclarativeView *createView(const QString &filename);
+};
+
+void tst_QDeclarativeMouseArea::dragProperties()
+{
+ QDeclarativeView *canvas = createView(SRCDIR "/data/dragproperties.qml");
+ canvas->show();
+ canvas->setFocus();
+ QVERIFY(canvas->rootObject() != 0);
+
+ QDeclarativeMouseArea *mouseRegion = canvas->rootObject()->findChild<QDeclarativeMouseArea*>("mouseregion");
+ QDeclarativeDrag *drag = mouseRegion->drag();
+ QVERIFY(mouseRegion != 0);
+ QVERIFY(drag != 0);
+
+ // target
+ QDeclarativeItem *blackRect = canvas->rootObject()->findChild<QDeclarativeItem*>("blackrect");
+ QVERIFY(blackRect != 0);
+ QVERIFY(blackRect == drag->target());
+ QDeclarativeItem *rootItem = qobject_cast<QDeclarativeItem*>(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(), QDeclarativeDrag::XandYAxis);
+ QSignalSpy axisSpy(drag, SIGNAL(axisChanged()));
+ drag->setAxis(QDeclarativeDrag::XAxis);
+ QCOMPARE(drag->axis(), QDeclarativeDrag::XAxis);
+ QCOMPARE(axisSpy.count(),1);
+ drag->setAxis(QDeclarativeDrag::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);
+}
+
+QDeclarativeView *tst_QDeclarativeMouseArea::createView(const QString &filename)
+{
+ QDeclarativeView *canvas = new QDeclarativeView(0);
+ canvas->setFixedSize(240,320);
+
+ canvas->setSource(QUrl::fromLocalFile(filename));
+
+ return canvas;
+}
+
+QTEST_MAIN(tst_QDeclarativeMouseArea)
+
+#include "tst_qdeclarativemousearea.moc"
diff --git a/tests/auto/declarative/qdeclarativenumberformatter/qdeclarativenumberformatter.pro b/tests/auto/declarative/qdeclarativenumberformatter/qdeclarativenumberformatter.pro
new file mode 100644
index 0000000..672e95c
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativenumberformatter/qdeclarativenumberformatter.pro
@@ -0,0 +1,5 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qdeclarativenumberformatter.cpp
diff --git a/tests/auto/declarative/qdeclarativenumberformatter/tst_qdeclarativenumberformatter.cpp b/tests/auto/declarative/qdeclarativenumberformatter/tst_qdeclarativenumberformatter.cpp
new file mode 100644
index 0000000..26ff3d5
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativenumberformatter/tst_qdeclarativenumberformatter.cpp
@@ -0,0 +1,222 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QDebug>
+#include <QtDeclarative/qdeclarativeengine.h>
+#include <QtDeclarative/qdeclarativecomponent.h>
+#include <private/qnumberformat_p.h>
+#include <private/qdeclarativenumberformatter_p.h>
+
+class tst_qdeclarativenumberformatter : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qdeclarativenumberformatter();
+
+ void init() {}
+ void initTestCase() {}
+
+ void cleanup() {}
+ void cleanupTestCase() {}
+
+private slots:
+ void text_data();
+ void text();
+
+private:
+ QStringList strings;
+ QStringList formats;
+ QStringList texts;
+};
+
+tst_qdeclarativenumberformatter::tst_qdeclarativenumberformatter()
+{
+ strings << "100.0"
+ << "12345"
+ << "1234567"
+ << "0.123"
+ << "0.9999"
+ << "0.989"
+ << "1"
+ << "1.0"
+ << "1.01";
+
+ formats << ""
+ << "0000"
+ << "0000.00"
+ << "##"
+ << "##.##"
+ << "#0.00#"
+ << "##,##0.##"
+ << "(000) 000 - 000"
+ << "00000,000.0000";
+
+ //US locale only.
+ texts << "100.000000"
+ << "12345.000000"
+ << "1234567.000000"
+ << "0.123000"
+ << "0.999900"
+ << "0.989000"
+ << "1.000000"
+ << "1.000000"
+ << "1.010000" //end ""
+ << "0100"
+ << "12345"
+ << "1234567"
+ << "0000"
+ << "0001"
+ << "0001"
+ << "0001"
+ << "0001"
+ << "0001" // end "0000"
+ << "0100.00"
+ << "12345.00"
+ << "1234567.00"
+ << "0000.12"
+ << "0001.00"
+ << "0000.99"
+ << "0001.00"
+ << "0001.00"
+ << "0001.01" // end "0000.00"
+ << "100"
+ << "12345"
+ << "1234567"
+ << "0"
+ << "1"
+ << "1"
+ << "1"
+ << "1"
+ << "1" // end "##"
+ << "100"//start "##.##"
+ << "12345"
+ << "1234567"
+ << "0.12"
+ << "1"
+ << "0.99"
+ << "1"
+ << "1"
+ << "1.01" // end "##.##" -- ### EXPECT FAIL ### QNumberFormat::formatDecimal() bug
+ << "100.00" //start "#0.00#"
+ << "12345.00"
+ << "1234567.00"
+ << "0.123"
+ << "1.00"
+ << "0.989"
+ << "1.00"
+ << "1.00"
+ << "1.01" //end "#0.00#"
+ << "100" //start "##,##0.##"
+ << "12,345"
+ << "1,234,567"
+ << "0.12"
+ << "1"
+ << "0.99"
+ << "1"
+ << "1"
+ << "1.01" //end "##,##0.##" -- ### EXPECT FAIL ### QNumberFormat::formatDecimal() bug
+ << "(000) 000 - 100" //start "(000) 000 - 000"
+ << "(000) 012 - 345"
+ << "(001) 234 - 567"
+ << "(000) 000 - 000"
+ << "(000) 000 - 001"
+ << "(000) 000 - 001"
+ << "(000) 000 - 001"
+ << "(000) 000 - 001"
+ << "(000) 000 - 001" // end "(000) 000 - 000"
+ << "00,000,100.0000" // start "00000,000.0000"
+ << "00,012,345.0000"
+ << "01,234,567.0000"
+ << "00,000,000.1230"
+ << "00,000,000.9999"
+ << "00,000,000.9890"
+ << "00,000,001.0000"
+ << "00,000,001.0000"
+ << "00,000,001.0100"; // end
+
+ qDebug() << "strings.size()" << strings.size()
+ << "\nformats.size()" << formats.size()
+ << "texts.size()" << texts.size();
+}
+
+void tst_qdeclarativenumberformatter::text_data()
+{
+ QTest::addColumn<QString>("string");
+ QTest::addColumn<QString>("format");
+ QTest::addColumn<QString>("text");
+
+ for (int j=0; j < formats.size(); j++)
+ {
+ for (int i=0; i < strings.size(); i++)
+ {
+ QTest::newRow(QString("%1, %2").arg(strings.at(i)).arg(formats.at(j)).toAscii())
+ << strings.at(i) << formats.at(j) << texts.at(j*formats.size()+i);
+ }
+ }
+
+}
+
+void tst_qdeclarativenumberformatter::text()
+{
+ QFETCH(QString, string);
+ QFETCH(QString, format);
+ QFETCH(QString, text);
+
+ QString componentStr = QString("import Qt 4.6\nNumberFormatter { number: ") + string + QString("; format: \"") + format + QString("\" }");
+
+ QDeclarativeEngine engine;
+ QDeclarativeComponent formatterComponent(&engine);
+ formatterComponent.setData(componentStr.toUtf8(), QUrl::fromLocalFile(""));
+ if(formatterComponent.isError())
+ qDebug() << formatterComponent.errors();
+ QVERIFY(formatterComponent.isReady());
+ QDeclarativeNumberFormatter *formatter = qobject_cast<QDeclarativeNumberFormatter*>(formatterComponent.create());
+ QVERIFY(formatter != 0);
+
+ QCOMPARE(formatter->format(), format);
+ QCOMPARE(formatter->text(), text);
+
+ delete formatter;
+}
+
+QTEST_MAIN(tst_qdeclarativenumberformatter)
+
+#include "tst_qdeclarativenumberformatter.moc"
diff --git a/tests/auto/declarative/qmlgraphicsparticles/data/particle.png b/tests/auto/declarative/qdeclarativeparticles/data/particle.png
index defbde5..defbde5 100644
--- a/tests/auto/declarative/qmlgraphicsparticles/data/particle.png
+++ b/tests/auto/declarative/qdeclarativeparticles/data/particle.png
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativeparticles/data/particlemotion.qml b/tests/auto/declarative/qdeclarativeparticles/data/particlemotion.qml
new file mode 100644
index 0000000..ace61fe
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeparticles/data/particlemotion.qml
@@ -0,0 +1,33 @@
+import Qt 4.6
+Rectangle {
+ width: 240
+ height: 320
+ color: "black"
+ Particles {
+ objectName: "particles"
+ anchors.fill: parent
+ width: 1
+ height: 1
+ source: "particle.png"
+ lifeSpan: 5000
+ count: 200
+ angle: 270
+ angleDeviation: 45
+ velocity: 50
+ velocityDeviation: 30
+ ParticleMotionGravity {
+ objectName: "motionGravity"
+ yattractor: 1000
+ xattractor: 0
+ acceleration: 25
+ }
+ }
+ resources: [
+ ParticleMotionWander {
+ objectName: "motionWander"
+ xvariance: 30
+ yvariance: 30
+ pace: 100
+ }
+ ]
+} \ No newline at end of file
diff --git a/tests/auto/declarative/qmlgraphicsparticles/data/particles.qml b/tests/auto/declarative/qdeclarativeparticles/data/particles.qml
index c58927e..c58927e 100644
--- a/tests/auto/declarative/qmlgraphicsparticles/data/particles.qml
+++ b/tests/auto/declarative/qdeclarativeparticles/data/particles.qml
diff --git a/tests/auto/declarative/qdeclarativeparticles/qdeclarativeparticles.pro b/tests/auto/declarative/qdeclarativeparticles/qdeclarativeparticles.pro
new file mode 100644
index 0000000..043bb85
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeparticles/qdeclarativeparticles.pro
@@ -0,0 +1,8 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative gui
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qdeclarativeparticles.cpp
+
+# Define SRCDIR equal to test's source directory
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qdeclarativeparticles/tst_qdeclarativeparticles.cpp b/tests/auto/declarative/qdeclarativeparticles/tst_qdeclarativeparticles.cpp
new file mode 100644
index 0000000..6090a07
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeparticles/tst_qdeclarativeparticles.cpp
@@ -0,0 +1,209 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QtTest/QtTest>
+#include <QtTest/QSignalSpy>
+#include <qdeclarativeview.h>
+#include <private/qdeclarativeparticles_p.h>
+
+class tst_QDeclarativeParticles : public QObject
+{
+ Q_OBJECT
+public:
+ tst_QDeclarativeParticles();
+
+private slots:
+ void properties();
+ void motionGravity();
+ void motionWander();
+ void runs();
+private:
+ QDeclarativeView *createView(const QString &filename);
+
+};
+
+tst_QDeclarativeParticles::tst_QDeclarativeParticles()
+{
+}
+
+void tst_QDeclarativeParticles::properties()
+{
+ QDeclarativeView *canvas = createView(SRCDIR "/data/particles.qml");
+ QVERIFY(canvas->rootObject());
+ QDeclarativeParticles* particles = canvas->rootObject()->findChild<QDeclarativeParticles*>("particles");
+ QVERIFY(particles);
+
+ particles->setSource(QUrl::fromLocalFile(SRCDIR "/data/particle.png"));
+ QCOMPARE(particles->source(), QUrl::fromLocalFile(SRCDIR "/data/particle.png"));
+
+ particles->setLifeSpanDeviation(1000);
+ QCOMPARE(particles->lifeSpanDeviation(), 1000);
+
+ particles->setFadeInDuration(1000);
+ QCOMPARE(particles->fadeInDuration(), 1000);
+
+ particles->setFadeOutDuration(1000);
+ QCOMPARE(particles->fadeOutDuration(), 1000);
+
+ particles->setAngle(100.0);
+ QCOMPARE(particles->angle(), 100.0);
+
+ particles->setAngleDeviation(100.0);
+ QCOMPARE(particles->angleDeviation(), 100.0);
+
+ particles->setVelocity(100.0);
+ QCOMPARE(particles->velocity(), 100.0);
+
+ particles->setVelocityDeviation(100.0);
+ QCOMPARE(particles->velocityDeviation(), 100.0);
+
+ particles->setEmissionVariance(0.5);
+ QCOMPARE(particles->emissionVariance(),0.5);
+
+ particles->setEmissionRate(12);
+ QCOMPARE(particles->emissionRate(), 12);
+}
+
+void tst_QDeclarativeParticles::motionGravity()
+{
+ QDeclarativeView *canvas = createView(SRCDIR "/data/particlemotion.qml");
+ QVERIFY(canvas->rootObject());
+ QDeclarativeParticles* particles = canvas->rootObject()->findChild<QDeclarativeParticles*>("particles");
+ QVERIFY(particles);
+
+ QDeclarativeParticleMotionGravity* motionGravity = canvas->rootObject()->findChild<QDeclarativeParticleMotionGravity*>("motionGravity");
+ QCOMPARE(particles->motion(), motionGravity);
+
+ QSignalSpy xattractorSpy(motionGravity, SIGNAL(xattractorChanged()));
+ QSignalSpy yattractorSpy(motionGravity, SIGNAL(yattractorChanged()));
+ QSignalSpy accelerationSpy(motionGravity, SIGNAL(accelerationChanged()));
+
+ QCOMPARE(motionGravity->xAttractor(), 0.0);
+ QCOMPARE(motionGravity->yAttractor(), 1000.0);
+ QCOMPARE(motionGravity->acceleration(), 25.0);
+
+ motionGravity->setXAttractor(20.0);
+ motionGravity->setYAttractor(10.0);
+ motionGravity->setAcceleration(10.0);
+
+ QCOMPARE(motionGravity->xAttractor(), 20.0);
+ QCOMPARE(motionGravity->yAttractor(), 10.0);
+ QCOMPARE(motionGravity->acceleration(), 10.0);
+
+ QCOMPARE(xattractorSpy.count(), 1);
+ QCOMPARE(yattractorSpy.count(), 1);
+ QCOMPARE(accelerationSpy.count(), 1);
+
+ motionGravity->setXAttractor(20.0);
+ motionGravity->setYAttractor(10.0);
+ motionGravity->setAcceleration(10.0);
+
+ QCOMPARE(xattractorSpy.count(), 1);
+ QCOMPARE(yattractorSpy.count(), 1);
+ QCOMPARE(accelerationSpy.count(), 1);
+}
+
+void tst_QDeclarativeParticles::motionWander()
+{
+ QDeclarativeView *canvas = createView(SRCDIR "/data/particlemotion.qml");
+ QVERIFY(canvas->rootObject());
+ QDeclarativeParticles* particles = canvas->rootObject()->findChild<QDeclarativeParticles*>("particles");
+ QVERIFY(particles);
+
+ QSignalSpy motionSpy(particles, SIGNAL(motionChanged()));
+ QDeclarativeParticleMotionWander* motionWander = canvas->rootObject()->findChild<QDeclarativeParticleMotionWander*>("motionWander");
+
+ particles->setMotion(motionWander);
+ QCOMPARE(particles->motion(),motionWander);
+ QCOMPARE(motionSpy.count(), 1);
+
+ particles->setMotion(motionWander);
+ QCOMPARE(motionSpy.count(), 1);
+
+ QSignalSpy xvarianceSpy(motionWander, SIGNAL(xvarianceChanged()));
+ QSignalSpy yvarianceSpy(motionWander, SIGNAL(yvarianceChanged()));
+ QSignalSpy paceSpy(motionWander, SIGNAL(paceChanged()));
+
+ QCOMPARE(motionWander->xVariance(), 30.0);
+ QCOMPARE(motionWander->yVariance(), 30.0);
+ QCOMPARE(motionWander->pace(), 100.0);
+
+ motionWander->setXVariance(20.0);
+ motionWander->setYVariance(10.0);
+ motionWander->setPace(10.0);
+
+ QCOMPARE(motionWander->xVariance(), 20.0);
+ QCOMPARE(motionWander->yVariance(), 10.0);
+ QCOMPARE(motionWander->pace(), 10.0);
+
+ QCOMPARE(xvarianceSpy.count(), 1);
+ QCOMPARE(yvarianceSpy.count(), 1);
+ QCOMPARE(paceSpy.count(), 1);
+
+ motionWander->setXVariance(20.0);
+ motionWander->setYVariance(10.0);
+ motionWander->setPace(10.0);
+
+ QCOMPARE(xvarianceSpy.count(), 1);
+ QCOMPARE(yvarianceSpy.count(), 1);
+ QCOMPARE(paceSpy.count(), 1);
+}
+
+void tst_QDeclarativeParticles::runs()
+{
+ QDeclarativeView *canvas = createView(SRCDIR "/data/particles.qml");
+ QVERIFY(canvas->rootObject());
+ QDeclarativeParticles* particles = canvas->rootObject()->findChild<QDeclarativeParticles*>("particles");
+ QVERIFY(particles);
+ QTest::qWait(1000);//Run for one second. Test passes if it doesn't crash.
+}
+
+QDeclarativeView *tst_QDeclarativeParticles::createView(const QString &filename)
+{
+ QDeclarativeView *canvas = new QDeclarativeView(0);
+ canvas->setFixedSize(240,320);
+
+ canvas->setSource(QUrl::fromLocalFile(filename));
+
+ return canvas;
+}
+QTEST_MAIN(tst_QDeclarativeParticles)
+
+#include "tst_qdeclarativeparticles.moc"
diff --git a/tests/auto/declarative/qmlgraphicspathview/data/datamodel.qml b/tests/auto/declarative/qdeclarativepathview/data/datamodel.qml
index 8d07db2..8d07db2 100644
--- a/tests/auto/declarative/qmlgraphicspathview/data/datamodel.qml
+++ b/tests/auto/declarative/qdeclarativepathview/data/datamodel.qml
diff --git a/tests/auto/declarative/qdeclarativepathview/data/displaypath.qml b/tests/auto/declarative/qdeclarativepathview/data/displaypath.qml
new file mode 100644
index 0000000..627f38a
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativepathview/data/displaypath.qml
@@ -0,0 +1,60 @@
+import Qt 4.6
+
+Rectangle {
+ width: 240
+ height: 320
+ color: "#ffffff"
+ resources: [
+ Component {
+ id: delegate
+ Rectangle {
+ id: wrapper
+ objectName: "wrapper"
+ height: 20
+ width: 60
+ color: "white"
+ border.color: "black"
+ Text {
+ text: index
+ }
+ Text {
+ x: 20
+ id: displayText
+ objectName: "displayText"
+ text: display
+ }
+ }
+ }
+ ]
+ PathView {
+ id: view
+ objectName: "view"
+ width: 240
+ height: 320
+ model: testModel
+ delegate: delegate
+ snapPosition: 0.01
+ path: Path {
+ startY: 120
+ startX: 160
+ PathQuad {
+ y: 120
+ x: 80
+ controlY: 330
+ controlX: 100
+ }
+ PathLine {
+ y: 160
+ x: 20
+ }
+ PathCubic {
+ y: 120
+ x: 160
+ control1Y: 0
+ control1X: 100
+ control2Y: 000
+ control2X: 200
+ }
+ }
+ }
+}
diff --git a/tests/auto/declarative/qmlgraphicspathview/data/path.qml b/tests/auto/declarative/qdeclarativepathview/data/path.qml
index 7e82a48..7e82a48 100644
--- a/tests/auto/declarative/qmlgraphicspathview/data/path.qml
+++ b/tests/auto/declarative/qdeclarativepathview/data/path.qml
diff --git a/tests/auto/declarative/qmlgraphicspathview/data/pathview.qml b/tests/auto/declarative/qdeclarativepathview/data/pathview.qml
index 8fa8d59..8fa8d59 100644
--- a/tests/auto/declarative/qmlgraphicspathview/data/pathview.qml
+++ b/tests/auto/declarative/qdeclarativepathview/data/pathview.qml
diff --git a/tests/auto/declarative/qmlgraphicspathview/data/pathview1.qml b/tests/auto/declarative/qdeclarativepathview/data/pathview1.qml
index b3b0a9a..b3b0a9a 100644
--- a/tests/auto/declarative/qmlgraphicspathview/data/pathview1.qml
+++ b/tests/auto/declarative/qdeclarativepathview/data/pathview1.qml
diff --git a/tests/auto/declarative/qmlgraphicspathview/data/pathview2.qml b/tests/auto/declarative/qdeclarativepathview/data/pathview2.qml
index 0d5c98b..0d5c98b 100644
--- a/tests/auto/declarative/qmlgraphicspathview/data/pathview2.qml
+++ b/tests/auto/declarative/qdeclarativepathview/data/pathview2.qml
diff --git a/tests/auto/declarative/qmlgraphicspathview/data/pathview3.qml b/tests/auto/declarative/qdeclarativepathview/data/pathview3.qml
index 412cca2..412cca2 100644
--- a/tests/auto/declarative/qmlgraphicspathview/data/pathview3.qml
+++ b/tests/auto/declarative/qdeclarativepathview/data/pathview3.qml
diff --git a/tests/auto/declarative/qdeclarativepathview/qdeclarativepathview.pro b/tests/auto/declarative/qdeclarativepathview/qdeclarativepathview.pro
new file mode 100644
index 0000000..2f6ae32
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativepathview/qdeclarativepathview.pro
@@ -0,0 +1,8 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qdeclarativepathview.cpp
+
+# Define SRCDIR equal to test's source directory
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp
new file mode 100644
index 0000000..79bc607
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp
@@ -0,0 +1,529 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <private/qdeclarativepathview_p.h>
+#include <private/qdeclarativepath_p.h>
+#include <qdeclarativecontext.h>
+#include <qdeclarativeexpression.h>
+#include <qtest.h>
+#include <QtDeclarative/qdeclarativeengine.h>
+#include <QtDeclarative/qdeclarativecomponent.h>
+#include <QtDeclarative/qdeclarativeview.h>
+#include <QtDeclarative/private/qdeclarativetext_p.h>
+#include <QtDeclarative/private/qdeclarativerectangle_p.h>
+#include <QAbstractListModel>
+#include <QStringListModel>
+#include <QFile>
+#include <private/qdeclarativevaluetype_p.h>
+#include "../../../shared/util.h"
+
+class tst_QDeclarativePathView : public QObject
+{
+ Q_OBJECT
+public:
+ tst_QDeclarativePathView();
+
+private slots:
+ void initValues();
+ void items();
+ void dataModel();
+ void pathview2();
+ void pathview3();
+ void path();
+ void pathMoved();
+ void resetModel();
+
+private:
+ QDeclarativeView *createView();
+ template<typename T>
+ T *findItem(QGraphicsObject *parent, const QString &objectName, int index=-1);
+ template<typename T>
+ QList<T*> findItems(QGraphicsObject *parent, const QString &objectName);
+};
+
+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;
+};
+
+class TestModel : public QAbstractListModel
+{
+public:
+ enum Roles { Name = Qt::UserRole+1, Number = Qt::UserRole+2 };
+
+ TestModel(QObject *parent=0) : QAbstractListModel(parent) {
+ QHash<int, QByteArray> roles;
+ roles[Name] = "name";
+ roles[Number] = "number";
+ setRoleNames(roles);
+ }
+
+ int rowCount(const QModelIndex &parent=QModelIndex()) const { return list.count(); }
+ QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) 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 count() const { return rowCount(); }
+ QString name(int index) const { return list.at(index).first; }
+ QString number(int index) const { return list.at(index).second; }
+
+ void addItem(const QString &name, const QString &number) {
+ emit beginInsertRows(QModelIndex(), list.count(), list.count());
+ list.append(QPair<QString,QString>(name, number));
+ emit endInsertRows();
+ }
+
+ void 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 removeItem(int index) {
+ emit beginRemoveRows(QModelIndex(), index, index);
+ list.removeAt(index);
+ emit endRemoveRows();
+ }
+
+ void moveItem(int from, int to) {
+ emit beginMoveRows(QModelIndex(), from, from, QModelIndex(), to);
+ list.move(from, to);
+ emit endMoveRows();
+ }
+
+ void modifyItem(int idx, const QString &name, const QString &number) {
+ list[idx] = QPair<QString,QString>(name, number);
+ emit dataChanged(index(idx,0), index(idx,0));
+ }
+
+private:
+ QList<QPair<QString,QString> > list;
+};
+
+
+tst_QDeclarativePathView::tst_QDeclarativePathView()
+{
+}
+
+void tst_QDeclarativePathView::initValues()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/pathview1.qml"));
+ QDeclarativePathView *obj = qobject_cast<QDeclarativePathView*>(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->snapPosition(), 0.);
+ QCOMPARE(obj->dragMargin(), 0.);
+ QCOMPARE(obj->count(), 0);
+ QCOMPARE(obj->pathItemCount(), -1);
+}
+
+void tst_QDeclarativePathView::items()
+{
+ QDeclarativeView *canvas = createView();
+
+ TestModel model;
+ model.addItem("Fred", "12345");
+ model.addItem("John", "2345");
+ model.addItem("Bob", "54321");
+
+ QDeclarativeContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/pathview.qml"));
+ qApp->processEvents();
+
+ QDeclarativePathView *pathview = findItem<QDeclarativePathView>(canvas->rootObject(), "view");
+ QVERIFY(pathview != 0);
+
+ QCOMPARE(pathview->childItems().count(), model.count()); // assumes all are visible
+
+ for (int i = 0; i < model.count(); ++i) {
+ QDeclarativeText *name = findItem<QDeclarativeText>(pathview, "textName", i);
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), model.name(i));
+ QDeclarativeText *number = findItem<QDeclarativeText>(pathview, "textNumber", i);
+ QVERIFY(number != 0);
+ QCOMPARE(number->text(), model.number(i));
+ }
+
+ delete canvas;
+}
+
+void tst_QDeclarativePathView::pathview2()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/pathview2.qml"));
+ QDeclarativePathView *obj = qobject_cast<QDeclarativePathView*>(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->snapPosition(), 0.);
+ QCOMPARE(obj->dragMargin(), 0.);
+ QCOMPARE(obj->count(), 8);
+ QCOMPARE(obj->pathItemCount(), 10);
+}
+
+void tst_QDeclarativePathView::pathview3()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/pathview3.qml"));
+ QDeclarativePathView *obj = qobject_cast<QDeclarativePathView*>(c.create());
+
+ QVERIFY(obj != 0);
+ QVERIFY(obj->path() != 0);
+ QVERIFY(obj->delegate() != 0);
+ QVERIFY(obj->model() != QVariant());
+ QCOMPARE(obj->currentIndex(), 0);
+ QCOMPARE(obj->offset(), 50.); // ???
+ QCOMPARE(obj->snapPosition(), 0.5); // ???
+ QCOMPARE(obj->dragMargin(), 24.);
+ QCOMPARE(obj->count(), 8);
+ QCOMPARE(obj->pathItemCount(), 4);
+}
+
+void tst_QDeclarativePathView::path()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/path.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.);
+}
+
+void tst_QDeclarativePathView::dataModel()
+{
+ QDeclarativeView *canvas = createView();
+
+ QDeclarativeContext *ctxt = canvas->rootContext();
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testObject", testObject);
+
+ TestModel 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");
+
+ ctxt->setContextProperty("testData", &model);
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/datamodel.qml"));
+ qApp->processEvents();
+
+ QDeclarativePathView *pathview = qobject_cast<QDeclarativePathView*>(canvas->rootObject());
+ QVERIFY(pathview != 0);
+
+ QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
+ QVERIFY(testObject->error() == false);
+
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(pathview, "wrapper", 0);
+ QVERIFY(item);
+ QCOMPARE(item->x(), 110.0);
+ QCOMPARE(item->y(), 10.0);
+
+ model.insertItem(4, "orange", "10");
+
+ int itemCount = findItems<QDeclarativeItem>(pathview, "wrapper").count();
+ QCOMPARE(itemCount, 10);
+
+ QDeclarativeText *text = findItem<QDeclarativeText>(pathview, "myText", 4);
+ QVERIFY(text);
+ QCOMPARE(text->text(), model.name(4));
+
+ model.removeItem(2);
+ text = findItem<QDeclarativeText>(pathview, "myText", 2);
+ QVERIFY(text);
+ QCOMPARE(text->text(), model.name(2));
+
+ testObject->setPathItemCount(5);
+ QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
+ QVERIFY(testObject->error() == false);
+
+ itemCount = findItems<QDeclarativeItem>(pathview, "wrapper").count();
+ QCOMPARE(itemCount, 5);
+
+ QDeclarativeRectangle *testItem = findItem<QDeclarativeRectangle>(pathview, "wrapper", 4);
+ QVERIFY(testItem != 0);
+ testItem = findItem<QDeclarativeRectangle>(pathview, "wrapper", 5);
+ QVERIFY(testItem == 0);
+
+ model.insertItem(2, "pink", "2");
+
+ itemCount = findItems<QDeclarativeItem>(pathview, "wrapper").count();
+ QCOMPARE(itemCount, 5);
+
+ text = findItem<QDeclarativeText>(pathview, "myText", 2);
+ QVERIFY(text);
+ QCOMPARE(text->text(), model.name(2));
+
+ model.removeItem(3);
+ itemCount = findItems<QDeclarativeItem>(pathview, "wrapper").count();
+ QCOMPARE(itemCount, 5);
+ text = findItem<QDeclarativeText>(pathview, "myText", 3);
+ QVERIFY(text);
+ QCOMPARE(text->text(), model.name(3));
+
+ delete canvas;
+}
+
+void tst_QDeclarativePathView::pathMoved()
+{
+ QDeclarativeView *canvas = createView();
+
+ TestModel 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(QUrl::fromLocalFile(SRCDIR "/data/pathview.qml"));
+ qApp->processEvents();
+
+ QDeclarativePathView *pathview = findItem<QDeclarativePathView>(canvas->rootObject(), "view");
+ QVERIFY(pathview != 0);
+
+ QDeclarativeRectangle *firstItem = findItem<QDeclarativeRectangle>(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);
+ pathview->setOffset(10);
+ QTest::qWait(1000);//Moving is animated?
+
+ for(int i=0; i<model.count(); i++){
+ QDeclarativeRectangle *curItem = findItem<QDeclarativeRectangle>(pathview, "wrapper", i);
+ QCOMPARE(curItem->pos() + offset, path->pointAt(0.1 + i*0.25));
+ }
+
+ pathview->setOffset(100);
+ QTest::qWait(1000);//Moving is animated?
+ QCOMPARE(firstItem->pos() + offset, start);
+
+ delete canvas;
+}
+
+void tst_QDeclarativePathView::resetModel()
+{
+ QDeclarativeView *canvas = createView();
+
+ QStringList strings;
+ strings << "one" << "two" << "three";
+ QStringListModel model(strings);
+
+ QDeclarativeContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/displaypath.qml"));
+ qApp->processEvents();
+
+ QDeclarativePathView *pathview = findItem<QDeclarativePathView>(canvas->rootObject(), "view");
+ QVERIFY(pathview != 0);
+
+ QCOMPARE(pathview->count(), model.rowCount());
+
+ for (int i = 0; i < model.rowCount(); ++i) {
+ QDeclarativeText *display = findItem<QDeclarativeText>(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) {
+ QDeclarativeText *display = findItem<QDeclarativeText>(pathview, "displayText", i);
+ QVERIFY(display != 0);
+ QCOMPARE(display->text(), strings.at(i));
+ }
+}
+
+
+QDeclarativeView *tst_QDeclarativePathView::createView()
+{
+ QDeclarativeView *canvas = new QDeclarativeView(0);
+ canvas->setFixedSize(240,320);
+
+ return canvas;
+}
+
+/*
+ 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 *tst_QDeclarativePathView::findItem(QGraphicsObject *parent, const QString &objectName, int index)
+{
+ const QMetaObject &mo = T::staticMetaObject;
+ //qDebug() << parent->childItems().count() << "children";
+ for (int i = 0; i < parent->childItems().count(); ++i) {
+ QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(parent->childItems().at(i));
+ if(!item)
+ continue;
+ //qDebug() << "try" << item;
+ if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) {
+ if (index != -1) {
+ QDeclarativeExpression e(qmlContext(item), "index", item);
+ if (e.value().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*> tst_QDeclarativePathView::findItems(QGraphicsObject *parent, const QString &objectName)
+{
+ QList<T*> items;
+ const QMetaObject &mo = T::staticMetaObject;
+ //qDebug() << parent->QGraphicsObject::children().count() << "children";
+ for (int i = 0; i < parent->childItems().count(); ++i) {
+ QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(parent->childItems().at(i));
+ if(!item)
+ continue;
+ //qDebug() << "try" << item;
+ if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName))
+ items.append(static_cast<T*>(item));
+ items += findItems<T>(item, objectName);
+ }
+
+ return items;
+}
+
+QTEST_MAIN(tst_QDeclarativePathView)
+
+#include "tst_qdeclarativepathview.moc"
diff --git a/tests/auto/declarative/qmlimageprovider/data/exists.png b/tests/auto/declarative/qdeclarativepixmapcache/data/exists.png
index 399bd0b..399bd0b 100644
--- a/tests/auto/declarative/qmlimageprovider/data/exists.png
+++ b/tests/auto/declarative/qdeclarativepixmapcache/data/exists.png
Binary files differ
diff --git a/tests/auto/declarative/qmlimageprovider/data/exists1.png b/tests/auto/declarative/qdeclarativepixmapcache/data/exists1.png
index 399bd0b..399bd0b 100644
--- a/tests/auto/declarative/qmlimageprovider/data/exists1.png
+++ b/tests/auto/declarative/qdeclarativepixmapcache/data/exists1.png
Binary files differ
diff --git a/tests/auto/declarative/qmlimageprovider/data/exists2.png b/tests/auto/declarative/qdeclarativepixmapcache/data/exists2.png
index 399bd0b..399bd0b 100644
--- a/tests/auto/declarative/qmlimageprovider/data/exists2.png
+++ b/tests/auto/declarative/qdeclarativepixmapcache/data/exists2.png
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativepixmapcache/qdeclarativepixmapcache.pro b/tests/auto/declarative/qdeclarativepixmapcache/qdeclarativepixmapcache.pro
new file mode 100644
index 0000000..899c43f
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativepixmapcache/qdeclarativepixmapcache.pro
@@ -0,0 +1,9 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative
+QT += network
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qdeclarativepixmapcache.cpp
+
+# QMAKE_CXXFLAGS = -fprofile-arcs -ftest-coverage
+# LIBS += -lgcov
diff --git a/tests/auto/declarative/qdeclarativepixmapcache/tst_qdeclarativepixmapcache.cpp b/tests/auto/declarative/qdeclarativepixmapcache/tst_qdeclarativepixmapcache.cpp
new file mode 100644
index 0000000..223f54f
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativepixmapcache/tst_qdeclarativepixmapcache.cpp
@@ -0,0 +1,282 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QtTest/QtTest>
+#include <private/qdeclarativepixmapcache_p.h>
+#include <QtDeclarative/qdeclarativeengine.h>
+#include <QNetworkReply>
+
+// These don't let normal people run tests!
+//#include "../network-settings.h"
+
+class tst_qdeclarativepixmapcache : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qdeclarativepixmapcache() :
+ thisfile(QUrl::fromLocalFile(__FILE__))
+ {
+ }
+
+private slots:
+ void single();
+ void single_data();
+ void parallel();
+ void parallel_data();
+
+private:
+ QDeclarativeEngine engine;
+ QUrl thisfile;
+};
+
+
+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::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") << thisfile.resolved(QUrl("data/exists.png")) << localfile_optimized << true << false;
+ QTest::newRow("local") << thisfile.resolved(QUrl("data/notexists.png")) << localfile_optimized << false << false;
+ QTest::newRow("remote") << QUrl("http://qt.nokia.com/logo.png") << false << true << false;
+ QTest::newRow("remote") << QUrl("http://qt.nokia.com/thereisnologo.png") << false << false << true;
+}
+
+void tst_qdeclarativepixmapcache::single()
+{
+ QFETCH(QUrl, target);
+ QFETCH(bool, incache);
+ QFETCH(bool, exists);
+ QFETCH(bool, neterror);
+
+ if (neterror) {
+ QString expected = "\"Error downloading " + target.toString() + " - server replied: Not Found\" ";
+ QTest::ignoreMessage(QtWarningMsg, expected.toLatin1());
+ } else if (!exists) {
+ QString expected = "Cannot open QUrl( \"" + target.toString() + "\" ) ";
+ QTest::ignoreMessage(QtWarningMsg, expected.toLatin1());
+ }
+
+ QPixmap pixmap;
+ QVERIFY(pixmap.width() <= 0); // Check Qt assumption
+ QDeclarativePixmapReply::Status status = QDeclarativePixmapCache::get(target, &pixmap);
+
+ if (incache) {
+ if (exists) {
+ QVERIFY(status == QDeclarativePixmapReply::Ready);
+ QVERIFY(pixmap.width() > 0);
+ } else {
+ QVERIFY(status == QDeclarativePixmapReply::Error);
+ QVERIFY(pixmap.width() <= 0);
+ }
+ } else {
+ QDeclarativePixmapReply *reply = QDeclarativePixmapCache::request(&engine, target);
+ QVERIFY(reply);
+ QVERIFY(pixmap.width() <= 0);
+
+ Slotter getter;
+ connect(reply, SIGNAL(finished()), &getter, SLOT(got()));
+ QTestEventLoop::instance().enterLoop(10);
+ QVERIFY(!QTestEventLoop::instance().timeout());
+ QVERIFY(getter.gotslot);
+ if (exists) {
+ QVERIFY(QDeclarativePixmapCache::get(target, &pixmap) == QDeclarativePixmapReply::Ready);
+ QVERIFY(pixmap.width() > 0);
+ } else {
+ QVERIFY(QDeclarativePixmapCache::get(target, &pixmap) == QDeclarativePixmapReply::Error);
+ QVERIFY(pixmap.width() <= 0);
+ }
+ }
+
+ QCOMPARE(QDeclarativePixmapCache::pendingRequests(), 0);
+}
+
+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::addColumn<int>("requests");
+
+ QTest::newRow("local")
+ << thisfile.resolved(QUrl("data/exists1.png"))
+ << thisfile.resolved(QUrl("data/exists2.png"))
+ << (localfile_optimized ? 2 : 0)
+ << -1
+ << (localfile_optimized ? 0 : 2)
+ ;
+
+ QTest::newRow("remote")
+ << QUrl("http://qt.nokia.com/images/template/checkbox-on.png")
+ << QUrl("http://qt.nokia.com/images/products/qt-logo/image_tile")
+ << 0
+ << -1
+ << 2
+ ;
+
+ QTest::newRow("remoteagain")
+ << QUrl("http://qt.nokia.com/images/template/checkbox-on.png")
+ << QUrl("http://qt.nokia.com/images/products/qt-logo/image_tile")
+ << 2
+ << -1
+ << 0
+ ;
+
+ QTest::newRow("remotecopy")
+ << QUrl("http://qt.nokia.com/images/template/checkbox-off.png")
+ << QUrl("http://qt.nokia.com/images/template/checkbox-off.png")
+ << 0
+ << -1
+ << 1
+ ;
+
+ QTest::newRow("remotecopycancel")
+ << QUrl("http://qt.nokia.com/rounded_block_bg.png")
+ << QUrl("http://qt.nokia.com/rounded_block_bg.png")
+ << 0
+ << 0
+ << 1
+ ;
+}
+
+void tst_qdeclarativepixmapcache::parallel()
+{
+ QFETCH(QUrl, target1);
+ QFETCH(QUrl, target2);
+ QFETCH(int, incache);
+ QFETCH(int, cancel);
+ QFETCH(int, requests);
+
+ QList<QUrl> targets;
+ targets << target1 << target2;
+
+ QList<QDeclarativePixmapReply*> replies;
+ QList<Slotter*> getters;
+ for (int i=0; i<targets.count(); ++i) {
+ QUrl target = targets.at(i);
+ QPixmap pixmap;
+ QDeclarativePixmapReply::Status status = QDeclarativePixmapCache::get(target, &pixmap);
+ QDeclarativePixmapReply *reply = 0;
+ if (status != QDeclarativePixmapReply::Error && status != QDeclarativePixmapReply::Ready)
+ reply = QDeclarativePixmapCache::request(&engine, target);
+ replies.append(reply);
+ if (!reply) {
+ QVERIFY(pixmap.width() > 0);
+ getters.append(0);
+ } else {
+ QVERIFY(pixmap.width() <= 0);
+ getters.append(new Slotter);
+ connect(reply, SIGNAL(finished()), getters[i], SLOT(got()));
+ }
+ }
+
+ QCOMPARE(incache+slotters, targets.count());
+ QCOMPARE(QDeclarativePixmapCache::pendingRequests(), requests);
+
+ if (cancel >= 0) {
+ QDeclarativePixmapCache::cancel(targets.at(cancel), getters[cancel]);
+ slotters--;
+ }
+
+ if (slotters) {
+ QTestEventLoop::instance().enterLoop(10);
+ QVERIFY(!QTestEventLoop::instance().timeout());
+ }
+
+ for (int i=0; i<targets.count(); ++i) {
+ QDeclarativePixmapReply *reply = replies[i];
+ if (reply) {
+ if (i == cancel) {
+ QVERIFY(!getters[i]->gotslot);
+ } else {
+ QVERIFY(getters[i]->gotslot);
+ QPixmap pixmap;
+ QVERIFY(QDeclarativePixmapCache::get(targets[i], &pixmap) == QDeclarativePixmapReply::Ready);
+ QVERIFY(pixmap.width() > 0);
+ }
+ delete getters[i];
+ }
+ }
+
+ QCOMPARE(QDeclarativePixmapCache::pendingRequests(), 0);
+}
+
+QTEST_MAIN(tst_qdeclarativepixmapcache)
+
+#include "tst_qdeclarativepixmapcache.moc"
diff --git a/tests/auto/declarative/qmlgraphicspositioners/data/grid-animated.qml b/tests/auto/declarative/qdeclarativepositioners/data/grid-animated.qml
index f6376a1..f6376a1 100644
--- a/tests/auto/declarative/qmlgraphicspositioners/data/grid-animated.qml
+++ b/tests/auto/declarative/qdeclarativepositioners/data/grid-animated.qml
diff --git a/tests/auto/declarative/qmlgraphicspositioners/data/grid-spacing.qml b/tests/auto/declarative/qdeclarativepositioners/data/grid-spacing.qml
index 5b4a30d..5b4a30d 100644
--- a/tests/auto/declarative/qmlgraphicspositioners/data/grid-spacing.qml
+++ b/tests/auto/declarative/qdeclarativepositioners/data/grid-spacing.qml
diff --git a/tests/auto/declarative/qmlgraphicspositioners/data/grid.qml b/tests/auto/declarative/qdeclarativepositioners/data/grid.qml
index 830df6a..830df6a 100644
--- a/tests/auto/declarative/qmlgraphicspositioners/data/grid.qml
+++ b/tests/auto/declarative/qdeclarativepositioners/data/grid.qml
diff --git a/tests/auto/declarative/qmlgraphicspositioners/data/horizontal-animated.qml b/tests/auto/declarative/qdeclarativepositioners/data/horizontal-animated.qml
index c113a36..c113a36 100644
--- a/tests/auto/declarative/qmlgraphicspositioners/data/horizontal-animated.qml
+++ b/tests/auto/declarative/qdeclarativepositioners/data/horizontal-animated.qml
diff --git a/tests/auto/declarative/qmlgraphicspositioners/data/horizontal-spacing.qml b/tests/auto/declarative/qdeclarativepositioners/data/horizontal-spacing.qml
index 32bf775..32bf775 100644
--- a/tests/auto/declarative/qmlgraphicspositioners/data/horizontal-spacing.qml
+++ b/tests/auto/declarative/qdeclarativepositioners/data/horizontal-spacing.qml
diff --git a/tests/auto/declarative/qmlgraphicspositioners/data/horizontal.qml b/tests/auto/declarative/qdeclarativepositioners/data/horizontal.qml
index 06ae151..06ae151 100644
--- a/tests/auto/declarative/qmlgraphicspositioners/data/horizontal.qml
+++ b/tests/auto/declarative/qdeclarativepositioners/data/horizontal.qml
diff --git a/tests/auto/declarative/qdeclarativepositioners/data/propertychanges.qml b/tests/auto/declarative/qdeclarativepositioners/data/propertychanges.qml
new file mode 100644
index 0000000..4370a18
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativepositioners/data/propertychanges.qml
@@ -0,0 +1,39 @@
+import Qt 4.6
+
+Grid {
+ id: myGrid
+
+ width: 270
+ height: 270
+ x: 3
+ y: 3
+ columns: 4
+ spacing: 3
+
+ add: columnTransition
+ move: columnTransition
+
+ Repeater {
+ model: 20
+ Rectangle { color: "black"; width: 50; height: 50 }
+ }
+
+ data: [
+ Transition {
+ id: rowTransition
+ objectName: "rowTransition"
+ NumberAnimation {
+ properties: "x,y";
+ easing.type: "OutInCubic"
+ }
+ },
+ Transition {
+ id: columnTransition
+ objectName: "columnTransition"
+ NumberAnimation {
+ properties: "x,y";
+ easing.type: "OutInCubic"
+ }
+ }
+ ]
+}
diff --git a/tests/auto/declarative/qmlgraphicspositioners/data/repeater.qml b/tests/auto/declarative/qdeclarativepositioners/data/repeater.qml
index 2bc5e94..2bc5e94 100644
--- a/tests/auto/declarative/qmlgraphicspositioners/data/repeater.qml
+++ b/tests/auto/declarative/qdeclarativepositioners/data/repeater.qml
diff --git a/tests/auto/declarative/qmlgraphicspositioners/data/vertical-animated.qml b/tests/auto/declarative/qdeclarativepositioners/data/vertical-animated.qml
index 10f6cbb..10f6cbb 100644
--- a/tests/auto/declarative/qmlgraphicspositioners/data/vertical-animated.qml
+++ b/tests/auto/declarative/qdeclarativepositioners/data/vertical-animated.qml
diff --git a/tests/auto/declarative/qmlgraphicspositioners/data/vertical-spacing.qml b/tests/auto/declarative/qdeclarativepositioners/data/vertical-spacing.qml
index 69a8256..69a8256 100644
--- a/tests/auto/declarative/qmlgraphicspositioners/data/vertical-spacing.qml
+++ b/tests/auto/declarative/qdeclarativepositioners/data/vertical-spacing.qml
diff --git a/tests/auto/declarative/qmlgraphicspositioners/data/vertical.qml b/tests/auto/declarative/qdeclarativepositioners/data/vertical.qml
index 856c180..856c180 100644
--- a/tests/auto/declarative/qmlgraphicspositioners/data/vertical.qml
+++ b/tests/auto/declarative/qdeclarativepositioners/data/vertical.qml
diff --git a/tests/auto/declarative/qdeclarativepositioners/qdeclarativepositioners.pro b/tests/auto/declarative/qdeclarativepositioners/qdeclarativepositioners.pro
new file mode 100644
index 0000000..5edfa55
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativepositioners/qdeclarativepositioners.pro
@@ -0,0 +1,7 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative
+SOURCES += tst_qdeclarativepositioners.cpp
+macx:CONFIG -= app_bundle
+
+# Define SRCDIR equal to test's source directory
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp b/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp
new file mode 100644
index 0000000..3a8a892
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp
@@ -0,0 +1,455 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QtTest/QtTest>
+#include <private/qlistmodelinterface_p.h>
+#include <qdeclarativeview.h>
+#include <private/qdeclarativerectangle_p.h>
+#include <private/qdeclarativepositioners_p.h>
+#include <private/qdeclarativetransition_p.h>
+#include <qdeclarativeexpression.h>
+#include "../../../shared/util.h"
+
+class tst_QDeclarativePositioners : public QObject
+{
+ Q_OBJECT
+public:
+ tst_QDeclarativePositioners();
+
+private slots:
+ void test_horizontal();
+ void test_horizontal_spacing();
+ void test_horizontal_animated();
+ void test_vertical();
+ void test_vertical_spacing();
+ void test_vertical_animated();
+ void test_grid();
+ void test_grid_spacing();
+ void test_grid_animated();
+ void test_propertychanges();
+ void test_repeater();
+private:
+ QDeclarativeView *createView(const QString &filename);
+};
+
+tst_QDeclarativePositioners::tst_QDeclarativePositioners()
+{
+}
+
+void tst_QDeclarativePositioners::test_horizontal()
+{
+ QDeclarativeView *canvas = createView(SRCDIR "/data/horizontal.qml");
+
+ QDeclarativeRectangle *one = canvas->rootObject()->findChild<QDeclarativeRectangle*>("one");
+ QVERIFY(one != 0);
+
+ QDeclarativeRectangle *two = canvas->rootObject()->findChild<QDeclarativeRectangle*>("two");
+ QVERIFY(two != 0);
+
+ QDeclarativeRectangle *three = canvas->rootObject()->findChild<QDeclarativeRectangle*>("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);
+}
+
+void tst_QDeclarativePositioners::test_horizontal_spacing()
+{
+ QDeclarativeView *canvas = createView(SRCDIR "/data/horizontal-spacing.qml");
+
+ QDeclarativeRectangle *one = canvas->rootObject()->findChild<QDeclarativeRectangle*>("one");
+ QVERIFY(one != 0);
+
+ QDeclarativeRectangle *two = canvas->rootObject()->findChild<QDeclarativeRectangle*>("two");
+ QVERIFY(two != 0);
+
+ QDeclarativeRectangle *three = canvas->rootObject()->findChild<QDeclarativeRectangle*>("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);
+}
+
+void tst_QDeclarativePositioners::test_horizontal_animated()
+{
+ QDeclarativeView *canvas = createView(SRCDIR "/data/horizontal-animated.qml");
+
+ QDeclarativeRectangle *one = canvas->rootObject()->findChild<QDeclarativeRectangle*>("one");
+ QVERIFY(one != 0);
+
+ QDeclarativeRectangle *two = canvas->rootObject()->findChild<QDeclarativeRectangle*>("two");
+ QVERIFY(two != 0);
+
+ QDeclarativeRectangle *three = canvas->rootObject()->findChild<QDeclarativeRectangle*>("three");
+ QVERIFY(three != 0);
+
+ //Note that they animate in
+ QCOMPARE(one->x(), -100.0);
+ QCOMPARE(two->x(), -100.0);
+ QCOMPARE(three->x(), -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->x(), 0.0);
+ QTRY_COMPARE(one->y(), 0.0);
+ QTRY_COMPARE(two->opacity(), 0.0);
+ 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->setOpacity(1.0);
+ QCOMPARE(two->opacity(), 1.0);
+ QTest::qWait(0);//Let the animation start
+ QCOMPARE(two->x(), -100.0);
+ QCOMPARE(three->x(), 50.0);
+
+ QTRY_COMPARE(two->x(), 50.0);
+ QTRY_COMPARE(three->x(), 100.0);
+}
+
+void tst_QDeclarativePositioners::test_vertical()
+{
+ QDeclarativeView *canvas = createView(SRCDIR "/data/vertical.qml");
+
+ QDeclarativeRectangle *one = canvas->rootObject()->findChild<QDeclarativeRectangle*>("one");
+ QVERIFY(one != 0);
+
+ QDeclarativeRectangle *two = canvas->rootObject()->findChild<QDeclarativeRectangle*>("two");
+ QVERIFY(two != 0);
+
+ QDeclarativeRectangle *three = canvas->rootObject()->findChild<QDeclarativeRectangle*>("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);
+}
+
+void tst_QDeclarativePositioners::test_vertical_spacing()
+{
+ QDeclarativeView *canvas = createView(SRCDIR "/data/vertical-spacing.qml");
+
+ QDeclarativeRectangle *one = canvas->rootObject()->findChild<QDeclarativeRectangle*>("one");
+ QVERIFY(one != 0);
+
+ QDeclarativeRectangle *two = canvas->rootObject()->findChild<QDeclarativeRectangle*>("two");
+ QVERIFY(two != 0);
+
+ QDeclarativeRectangle *three = canvas->rootObject()->findChild<QDeclarativeRectangle*>("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);
+}
+
+void tst_QDeclarativePositioners::test_vertical_animated()
+{
+ QDeclarativeView *canvas = createView(SRCDIR "/data/vertical-animated.qml");
+
+ //Note that they animate in
+ QDeclarativeRectangle *one = canvas->rootObject()->findChild<QDeclarativeRectangle*>("one");
+ QVERIFY(one != 0);
+ QCOMPARE(one->y(), -100.0);
+
+ QDeclarativeRectangle *two = canvas->rootObject()->findChild<QDeclarativeRectangle*>("two");
+ QVERIFY(two != 0);
+ QCOMPARE(two->y(), -100.0);
+
+ QDeclarativeRectangle *three = canvas->rootObject()->findChild<QDeclarativeRectangle*>("three");
+ QVERIFY(three != 0);
+ QCOMPARE(three->y(), -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->opacity(), 0.0);
+ 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->setOpacity(1.0);
+ QTRY_COMPARE(two->opacity(), 1.0);
+ QTest::qWait(0);//Let the animation start
+ QCOMPARE(two->y(), -100.0);
+ QCOMPARE(three->y(), 50.0);
+
+ QTRY_COMPARE(two->y(), 50.0);
+ QTRY_COMPARE(three->y(), 100.0);
+
+}
+
+void tst_QDeclarativePositioners::test_grid()
+{
+ QDeclarativeView *canvas = createView(SRCDIR "/data/grid.qml");
+
+ QDeclarativeRectangle *one = canvas->rootObject()->findChild<QDeclarativeRectangle*>("one");
+ QVERIFY(one != 0);
+ QDeclarativeRectangle *two = canvas->rootObject()->findChild<QDeclarativeRectangle*>("two");
+ QVERIFY(two != 0);
+ QDeclarativeRectangle *three = canvas->rootObject()->findChild<QDeclarativeRectangle*>("three");
+ QVERIFY(three != 0);
+ QDeclarativeRectangle *four = canvas->rootObject()->findChild<QDeclarativeRectangle*>("four");
+ QVERIFY(four != 0);
+ QDeclarativeRectangle *five = canvas->rootObject()->findChild<QDeclarativeRectangle*>("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);
+}
+
+void tst_QDeclarativePositioners::test_grid_spacing()
+{
+ QDeclarativeView *canvas = createView(SRCDIR "/data/grid-spacing.qml");
+
+ QDeclarativeRectangle *one = canvas->rootObject()->findChild<QDeclarativeRectangle*>("one");
+ QVERIFY(one != 0);
+ QDeclarativeRectangle *two = canvas->rootObject()->findChild<QDeclarativeRectangle*>("two");
+ QVERIFY(two != 0);
+ QDeclarativeRectangle *three = canvas->rootObject()->findChild<QDeclarativeRectangle*>("three");
+ QVERIFY(three != 0);
+ QDeclarativeRectangle *four = canvas->rootObject()->findChild<QDeclarativeRectangle*>("four");
+ QVERIFY(four != 0);
+ QDeclarativeRectangle *five = canvas->rootObject()->findChild<QDeclarativeRectangle*>("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);
+}
+
+void tst_QDeclarativePositioners::test_grid_animated()
+{
+ QDeclarativeView *canvas = createView(SRCDIR "/data/grid-animated.qml");
+
+ //Note that all animate in
+ QDeclarativeRectangle *one = canvas->rootObject()->findChild<QDeclarativeRectangle*>("one");
+ QVERIFY(one != 0);
+ QCOMPARE(one->x(), -100.0);
+ QCOMPARE(one->y(), -100.0);
+
+ QDeclarativeRectangle *two = canvas->rootObject()->findChild<QDeclarativeRectangle*>("two");
+ QVERIFY(two != 0);
+ QCOMPARE(two->x(), -100.0);
+ QCOMPARE(two->y(), -100.0);
+
+ QDeclarativeRectangle *three = canvas->rootObject()->findChild<QDeclarativeRectangle*>("three");
+ QVERIFY(three != 0);
+ QCOMPARE(three->x(), -100.0);
+ QCOMPARE(three->y(), -100.0);
+
+ QDeclarativeRectangle *four = canvas->rootObject()->findChild<QDeclarativeRectangle*>("four");
+ QVERIFY(four != 0);
+ QCOMPARE(four->x(), -100.0);
+ QCOMPARE(four->y(), -100.0);
+
+ QDeclarativeRectangle *five = canvas->rootObject()->findChild<QDeclarativeRectangle*>("five");
+ QVERIFY(five != 0);
+ QCOMPARE(five->x(), -100.0);
+ QCOMPARE(five->y(), -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->opacity(), 0.0);
+ 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->setOpacity(1.0);
+ QCOMPARE(two->opacity(), 1.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);
+
+}
+void tst_QDeclarativePositioners::test_propertychanges()
+{
+ QDeclarativeView *canvas = createView("data/propertychanges.qml");
+
+ QDeclarativeGrid *grid = qobject_cast<QDeclarativeGrid*>(canvas->rootObject());
+ 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);
+}
+
+void tst_QDeclarativePositioners::test_repeater()
+{
+ QDeclarativeView *canvas = createView(SRCDIR "/data/repeater.qml");
+
+ QDeclarativeRectangle *one = canvas->rootObject()->findChild<QDeclarativeRectangle*>("one");
+ QVERIFY(one != 0);
+
+ QDeclarativeRectangle *two = canvas->rootObject()->findChild<QDeclarativeRectangle*>("two");
+ QVERIFY(two != 0);
+
+ QDeclarativeRectangle *three = canvas->rootObject()->findChild<QDeclarativeRectangle*>("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);
+}
+
+QDeclarativeView *tst_QDeclarativePositioners::createView(const QString &filename)
+{
+ QDeclarativeView *canvas = new QDeclarativeView(0);
+
+ canvas->setSource(QUrl::fromLocalFile(filename));
+
+ return canvas;
+}
+
+
+QTEST_MAIN(tst_QDeclarativePositioners)
+
+#include "tst_qdeclarativepositioners.moc"
diff --git a/tests/auto/declarative/qdeclarativeproperty/qdeclarativeproperty.pro b/tests/auto/declarative/qdeclarativeproperty/qdeclarativeproperty.pro
new file mode 100644
index 0000000..22e50cc
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeproperty/qdeclarativeproperty.pro
@@ -0,0 +1,5 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qdeclarativeproperty.cpp
diff --git a/tests/auto/declarative/qdeclarativeproperty/tst_qdeclarativeproperty.cpp b/tests/auto/declarative/qdeclarativeproperty/tst_qdeclarativeproperty.cpp
new file mode 100644
index 0000000..0333d98
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeproperty/tst_qdeclarativeproperty.cpp
@@ -0,0 +1,1322 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QtDeclarative/qdeclarativeengine.h>
+#include <QtDeclarative/qdeclarativecomponent.h>
+#include <QtDeclarative/qdeclarativeproperty.h>
+#include <QtDeclarative/private/qdeclarativeproperty_p.h>
+#include <private/qguard_p.h>
+#include <private/qdeclarativebinding_p.h>
+#include <QtGui/QLineEdit>
+
+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 QObject
+{
+ 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();
+
+ // Bugs
+ void crashOnValueProperty();
+
+ void copy();
+private:
+ QDeclarativeEngine engine;
+};
+
+void tst_qdeclarativeproperty::qmlmetaproperty()
+{
+ QDeclarativeProperty prop;
+
+ QGuard<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext()));
+ QVERIFY(binding != 0);
+ QGuard<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.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) == 0);
+ QVERIFY(binding == 0);
+ QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0);
+ QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression) == 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(int resettableProperty READ resettableProperty WRITE setResettableProperty RESET resetProperty);
+ Q_PROPERTY(int propertyWithNotify READ propertyWithNotify WRITE setPropertyWithNotify NOTIFY oddlyNamedNotifySignal)
+
+ 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; }
+
+ 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(); }
+
+signals:
+ void clicked();
+ void oddlyNamedNotifySignal();
+
+private:
+ int m_resetProperty;
+ QRect m_rect;
+ QUrl m_url;
+ int m_propertyWithNotify;
+};
+
+QML_DECLARE_TYPE(PropertyObject);
+
+void tst_qdeclarativeproperty::qmlmetaproperty_object()
+{
+ QObject object; // Has no default property
+ PropertyObject dobject; // Has default property
+
+ {
+ QDeclarativeProperty prop(&object);
+
+ QGuard<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext()));
+ QVERIFY(binding != 0);
+ QGuard<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.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) == 0);
+ QVERIFY(binding == 0);
+ QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0);
+ QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression) == 0);
+ QVERIFY(expression == 0);
+ QCOMPARE(prop.index(), -1);
+ QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1);
+
+ delete obj;
+ }
+
+ {
+ QDeclarativeProperty prop(&dobject);
+
+ QGuard<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext()));
+ binding->setTarget(prop);
+ QVERIFY(binding != 0);
+ QGuard<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.isValid(), true);
+ QCOMPARE(prop.object(), &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>:-1: Unable to assign null to int");
+ QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding) == 0);
+ QVERIFY(binding != 0);
+ QVERIFY(QDeclarativePropertyPrivate::binding(prop) == binding);
+ QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0);
+ QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression) == 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"));
+
+ QGuard<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext()));
+ QVERIFY(binding != 0);
+ QGuard<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.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) == 0);
+ QVERIFY(binding == 0);
+ QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0);
+ QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression) == 0);
+ QVERIFY(expression == 0);
+ QCOMPARE(prop.index(), -1);
+ QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1);
+
+ delete obj;
+ }
+
+ {
+ QDeclarativeProperty prop(&dobject, QString("defaultProperty"));
+
+ QGuard<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext()));
+ binding->setTarget(prop);
+ QVERIFY(binding != 0);
+ QGuard<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.isValid(), true);
+ QCOMPARE(prop.object(), &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>:-1: Unable to assign null to int");
+ QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding) == 0);
+ QVERIFY(binding != 0);
+ QVERIFY(QDeclarativePropertyPrivate::binding(prop) == binding);
+ QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0);
+ QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression) == 0);
+ QVERIFY(expression == 0);
+ QCOMPARE(prop.index(), dobject.metaObject()->indexOfProperty("defaultProperty"));
+ QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1);
+
+ delete obj;
+ }
+
+ {
+ QDeclarativeProperty prop(&dobject, QString("onClicked"));
+
+ QGuard<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext()));
+ binding->setTarget(prop);
+ QVERIFY(binding != 0);
+ QGuard<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.isValid(), true);
+ QCOMPARE(prop.object(), &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) == 0);
+ QVERIFY(binding == 0);
+ QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0);
+ QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression) == 0);
+ QVERIFY(expression != 0);
+ QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == expression);
+ QCOMPARE(prop.index(), dobject.metaObject()->indexOfMethod("clicked()"));
+ QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1);
+
+ delete obj;
+ }
+
+ {
+ QDeclarativeProperty prop(&dobject, QString("onPropertyWithNotifyChanged"));
+
+ QGuard<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext()));
+ binding->setTarget(prop);
+ QVERIFY(binding != 0);
+ QGuard<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.isValid(), true);
+ QCOMPARE(prop.object(), &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) == 0);
+ QVERIFY(binding == 0);
+ QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0);
+ QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression) == 0);
+ QVERIFY(expression != 0);
+ QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == expression);
+ 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());
+
+ QGuard<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext()));
+ QVERIFY(binding != 0);
+ QGuard<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.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) == 0);
+ QVERIFY(binding == 0);
+ QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0);
+ QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression) == 0);
+ QVERIFY(expression == 0);
+ QCOMPARE(prop.index(), -1);
+ QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1);
+
+ delete obj;
+ }
+
+ {
+ QDeclarativeProperty prop(&dobject, engine.rootContext());
+
+ QGuard<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext()));
+ binding->setTarget(prop);
+ QVERIFY(binding != 0);
+ QGuard<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.isValid(), true);
+ QCOMPARE(prop.object(), &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>:-1: Unable to assign null to int");
+ QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding) == 0);
+ QVERIFY(binding != 0);
+ QVERIFY(QDeclarativePropertyPrivate::binding(prop) == binding);
+ QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0);
+ QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression) == 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());
+
+ QGuard<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext()));
+ QVERIFY(binding != 0);
+ QGuard<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.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) == 0);
+ QVERIFY(binding == 0);
+ QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0);
+ QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression) == 0);
+ QVERIFY(expression == 0);
+ QCOMPARE(prop.index(), -1);
+ QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1);
+
+ delete obj;
+ }
+
+ {
+ QDeclarativeProperty prop(&dobject, QString("defaultProperty"), engine.rootContext());
+
+ QGuard<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext()));
+ binding->setTarget(prop);
+ QVERIFY(binding != 0);
+ QGuard<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.isValid(), true);
+ QCOMPARE(prop.object(), &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>:-1: Unable to assign null to int");
+ QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding) == 0);
+ QVERIFY(binding != 0);
+ QVERIFY(QDeclarativePropertyPrivate::binding(prop) == binding);
+ QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0);
+ QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression) == 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());
+
+ QGuard<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext()));
+ binding->setTarget(prop);
+ QVERIFY(binding != 0);
+ QGuard<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.isValid(), true);
+ QCOMPARE(prop.object(), &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) == 0);
+ QVERIFY(binding == 0);
+ QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0);
+ QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression) == 0);
+ QVERIFY(expression != 0);
+ QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == expression);
+ QCOMPARE(prop.index(), dobject.metaObject()->indexOfMethod("clicked()"));
+ QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1);
+
+ delete obj;
+ }
+
+ {
+ QDeclarativeProperty prop(&dobject, QString("onPropertyWithNotifyChanged"), engine.rootContext());
+
+ QGuard<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext()));
+ binding->setTarget(prop);
+ QVERIFY(binding != 0);
+ QGuard<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.isValid(), true);
+ QCOMPARE(prop.object(), &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) == 0);
+ QVERIFY(binding == 0);
+ QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0);
+ QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression) == 0);
+ QVERIFY(expression != 0);
+ QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == expression);
+ 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-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());
+ }
+
+ // 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;
+ }
+}
+
+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"));
+ }
+
+ // 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);
+ }
+
+ // 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), object);
+}
+
+Q_DECLARE_METATYPE(QList<QObject *>);
+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::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));
+}
+
+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::initTestCase()
+{
+ QML_REGISTER_TYPE(Test,1,0,MyQmlObject,MyQmlObject);
+ QML_REGISTER_TYPE(Test,1,0,PropertyObject,PropertyObject);
+ QML_REGISTER_TYPE(Test,1,0,MyContainer,MyContainer);
+}
+
+
+QTEST_MAIN(tst_qdeclarativeproperty)
+
+#include "tst_qdeclarativeproperty.moc"
diff --git a/tests/auto/declarative/qdeclarativepropertymap/qdeclarativepropertymap.pro b/tests/auto/declarative/qdeclarativepropertymap/qdeclarativepropertymap.pro
new file mode 100644
index 0000000..aeccf9b
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativepropertymap/qdeclarativepropertymap.pro
@@ -0,0 +1,5 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qdeclarativepropertymap.cpp
diff --git a/tests/auto/declarative/qdeclarativepropertymap/tst_qdeclarativepropertymap.cpp b/tests/auto/declarative/qdeclarativepropertymap/tst_qdeclarativepropertymap.cpp
new file mode 100644
index 0000000..22c5581
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativepropertymap/tst_qdeclarativepropertymap.cpp
@@ -0,0 +1,171 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QtDeclarative/qdeclarativeengine.h>
+#include <QtDeclarative/qdeclarativecontext.h>
+#include <QtDeclarative/qdeclarativepropertymap.h>
+#include <QtDeclarative/qdeclarativecomponent.h>
+#include <private/qdeclarativetext_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 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"));
+}
+
+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&)));
+ 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 Qt 4.6\nText { text: { testdata.key1 = 'Hello World'; 'X' } }",
+ QUrl::fromLocalFile(""));
+ QVERIFY(component.isReady());
+ QDeclarativeText *txt = qobject_cast<QDeclarativeText*>(component.create());
+ QVERIFY(txt);
+ QCOMPARE(txt->text(), QString('X'));
+ QCOMPARE(spy.count(), 1);
+ QList<QVariant> arguments = spy.takeFirst();
+ QCOMPARE(arguments.at(0).toString(),QLatin1String("key1"));
+ 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());
+}
+
+QTEST_MAIN(tst_QDeclarativePropertyMap)
+
+#include "tst_qdeclarativepropertymap.moc"
diff --git a/tests/auto/declarative/qmlqt/data/closestangle.qml b/tests/auto/declarative/qdeclarativeqt/data/closestangle.qml
index b5f7fc6..b5f7fc6 100644
--- a/tests/auto/declarative/qmlqt/data/closestangle.qml
+++ b/tests/auto/declarative/qdeclarativeqt/data/closestangle.qml
diff --git a/tests/auto/declarative/qmlqt/data/consoleLog.qml b/tests/auto/declarative/qdeclarativeqt/data/consoleLog.qml
index e657ff1..e657ff1 100644
--- a/tests/auto/declarative/qmlqt/data/consoleLog.qml
+++ b/tests/auto/declarative/qdeclarativeqt/data/consoleLog.qml
diff --git a/tests/auto/declarative/qmlqt/data/createComponent.qml b/tests/auto/declarative/qdeclarativeqt/data/createComponent.qml
index d9b70ec..d9b70ec 100644
--- a/tests/auto/declarative/qmlqt/data/createComponent.qml
+++ b/tests/auto/declarative/qdeclarativeqt/data/createComponent.qml
diff --git a/tests/auto/declarative/qmlqt/data/createComponentData.qml b/tests/auto/declarative/qdeclarativeqt/data/createComponentData.qml
index a5e99a0..a5e99a0 100644
--- a/tests/auto/declarative/qmlqt/data/createComponentData.qml
+++ b/tests/auto/declarative/qdeclarativeqt/data/createComponentData.qml
diff --git a/tests/auto/declarative/qmlqt/data/createQmlObject.qml b/tests/auto/declarative/qdeclarativeqt/data/createQmlObject.qml
index 9150782..9150782 100644
--- a/tests/auto/declarative/qmlqt/data/createQmlObject.qml
+++ b/tests/auto/declarative/qdeclarativeqt/data/createQmlObject.qml
diff --git a/tests/auto/declarative/qmlqt/data/darker.qml b/tests/auto/declarative/qdeclarativeqt/data/darker.qml
index 2df067e..2df067e 100644
--- a/tests/auto/declarative/qmlqt/data/darker.qml
+++ b/tests/auto/declarative/qdeclarativeqt/data/darker.qml
diff --git a/tests/auto/declarative/qmlqt/data/enums.qml b/tests/auto/declarative/qdeclarativeqt/data/enums.qml
index 1efa6f5..1efa6f5 100644
--- a/tests/auto/declarative/qmlqt/data/enums.qml
+++ b/tests/auto/declarative/qdeclarativeqt/data/enums.qml
diff --git a/tests/auto/declarative/qmlqt/data/hsla.qml b/tests/auto/declarative/qdeclarativeqt/data/hsla.qml
index df51ccd..df51ccd 100644
--- a/tests/auto/declarative/qmlqt/data/hsla.qml
+++ b/tests/auto/declarative/qdeclarativeqt/data/hsla.qml
diff --git a/tests/auto/declarative/qmlqt/data/lighter.qml b/tests/auto/declarative/qdeclarativeqt/data/lighter.qml
index 4e0c431..4e0c431 100644
--- a/tests/auto/declarative/qmlqt/data/lighter.qml
+++ b/tests/auto/declarative/qdeclarativeqt/data/lighter.qml
diff --git a/tests/auto/declarative/qmlqt/data/md5.qml b/tests/auto/declarative/qdeclarativeqt/data/md5.qml
index c474b71..c474b71 100644
--- a/tests/auto/declarative/qmlqt/data/md5.qml
+++ b/tests/auto/declarative/qdeclarativeqt/data/md5.qml
diff --git a/tests/auto/declarative/qmlqt/data/point.qml b/tests/auto/declarative/qdeclarativeqt/data/point.qml
index c383beb..c383beb 100644
--- a/tests/auto/declarative/qmlqt/data/point.qml
+++ b/tests/auto/declarative/qdeclarativeqt/data/point.qml
diff --git a/tests/auto/declarative/qmlqt/data/rect.qml b/tests/auto/declarative/qdeclarativeqt/data/rect.qml
index 82b6428..82b6428 100644
--- a/tests/auto/declarative/qmlqt/data/rect.qml
+++ b/tests/auto/declarative/qdeclarativeqt/data/rect.qml
diff --git a/tests/auto/declarative/qmlqt/data/rgba.qml b/tests/auto/declarative/qdeclarativeqt/data/rgba.qml
index 6dd6565..6dd6565 100644
--- a/tests/auto/declarative/qmlqt/data/rgba.qml
+++ b/tests/auto/declarative/qdeclarativeqt/data/rgba.qml
diff --git a/tests/auto/declarative/qmlqt/data/size.qml b/tests/auto/declarative/qdeclarativeqt/data/size.qml
index 05b0317..05b0317 100644
--- a/tests/auto/declarative/qmlqt/data/size.qml
+++ b/tests/auto/declarative/qdeclarativeqt/data/size.qml
diff --git a/tests/auto/declarative/qmlqt/data/tint.qml b/tests/auto/declarative/qdeclarativeqt/data/tint.qml
index da8afe2..da8afe2 100644
--- a/tests/auto/declarative/qmlqt/data/tint.qml
+++ b/tests/auto/declarative/qdeclarativeqt/data/tint.qml
diff --git a/tests/auto/declarative/qmlqt/data/vector.qml b/tests/auto/declarative/qdeclarativeqt/data/vector.qml
index a471c7a..a471c7a 100644
--- a/tests/auto/declarative/qmlqt/data/vector.qml
+++ b/tests/auto/declarative/qdeclarativeqt/data/vector.qml
diff --git a/tests/auto/declarative/qdeclarativeqt/qdeclarativeqt.pro b/tests/auto/declarative/qdeclarativeqt/qdeclarativeqt.pro
new file mode 100644
index 0000000..aff00ad
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeqt/qdeclarativeqt.pro
@@ -0,0 +1,9 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative
+SOURCES += tst_qdeclarativeqt.cpp
+macx:CONFIG -= app_bundle
+
+DEFINES += SRCDIR=\\\"$$PWD\\\"
+
+# QMAKE_CXXFLAGS = -fprofile-arcs -ftest-coverage
+# LIBS += -lgcov
diff --git a/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp b/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp
new file mode 100644
index 0000000..9ec6872
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp
@@ -0,0 +1,369 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+#include <QDebug>
+#include <QDeclarativeEngine>
+#include <QFileInfo>
+#include <QDeclarativeComponent>
+#include <QDir>
+#include <QVector3D>
+#include <QCryptographicHash>
+#include <QDeclarativeItem>
+
+class tst_qdeclarativeqt : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qdeclarativeqt() {}
+
+private slots:
+ void enums();
+ void rgba();
+ void hsla();
+ void rect();
+ void point();
+ void size();
+ void vector();
+ void lighter();
+ void darker();
+ void tint();
+ void closestAngle();
+ void playSound();
+ void openUrlExternally();
+ void md5();
+ void createComponent();
+ void createQmlObject();
+ void consoleLog();
+
+private:
+ QDeclarativeEngine engine;
+};
+
+inline QUrl TEST_FILE(const QString &filename)
+{
+ return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename);
+}
+
+void tst_qdeclarativeqt::enums()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("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, TEST_FILE("rgba.qml"));
+
+ QString warning1 = component.url().toString() + ":6: Unable to assign null to QColor";
+ QString warning2 = component.url().toString() + ":7: Unable to assign null to QColor";
+ QString warning3 = component.url().toString() + ":8: Unable to assign null to QColor";
+ QString warning4 = component.url().toString() + ":9: Unable to assign null to QColor";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning3));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning4));
+
+ 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());
+ QCOMPARE(qvariant_cast<QColor>(object->property("test6")), QColor());
+
+ delete object;
+}
+
+void tst_qdeclarativeqt::hsla()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("hsla.qml"));
+
+ QString warning1 = component.url().toString() + ":6: Unable to assign null to QColor";
+ QString warning2 = component.url().toString() + ":7: Unable to assign null to QColor";
+ QString warning3 = component.url().toString() + ":8: Unable to assign null to QColor";
+ QString warning4 = component.url().toString() + ":9: Unable to assign null to QColor";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning3));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning4));
+
+ 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());
+ QCOMPARE(qvariant_cast<QColor>(object->property("test6")), QColor());
+
+ delete object;
+}
+
+void tst_qdeclarativeqt::rect()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("rect.qml"));
+ 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());
+
+ delete object;
+}
+
+void tst_qdeclarativeqt::point()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("point.qml"));
+ 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, TEST_FILE("size.qml"));
+ 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, TEST_FILE("vector.qml"));
+ 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::lighter()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("lighter.qml"));
+ 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());
+ 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, TEST_FILE("darker.qml"));
+ 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());
+ 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, TEST_FILE("tint.qml"));
+
+ QString warning1 = component.url().toString() + ":7: Unable to assign null to QColor";
+ QString warning2 = component.url().toString() + ":8: Unable to assign null to QColor";
+ 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));
+ QEXPECT_FAIL("", "QT-2424",Continue);
+ QCOMPARE(qvariant_cast<QColor>(object->property("test3")), QColor::fromRgbF(1, 0, 0));
+ QCOMPARE(qvariant_cast<QColor>(object->property("test4")), QColor());
+ QCOMPARE(qvariant_cast<QColor>(object->property("test5")), QColor());
+
+ delete object;
+}
+
+void tst_qdeclarativeqt::closestAngle()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("closestangle.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(qvariant_cast<qreal>(object->property("testSame")), 1.0);
+ QCOMPARE(qvariant_cast<qreal>(object->property("testLess")), 1.0);
+ QCOMPARE(qvariant_cast<qreal>(object->property("testMore")), 1.0);
+ QCOMPARE(qvariant_cast<qreal>(object->property("testFail")), 0.0);
+ QCOMPARE(qvariant_cast<qreal>(object->property("test5")), 1.0);
+ QCOMPARE(qvariant_cast<qreal>(object->property("test6")), 1.11);
+ QCOMPARE(qvariant_cast<qreal>(object->property("test7")), 1.11);
+
+ delete object;
+}
+
+void tst_qdeclarativeqt::playSound()
+{
+ QEXPECT_FAIL("", "How do we test this?", Abort);
+ QVERIFY(false);
+}
+
+void tst_qdeclarativeqt::openUrlExternally()
+{
+ QEXPECT_FAIL("", "How do we test this?", Abort);
+ QVERIFY(false);
+}
+
+void tst_qdeclarativeqt::md5()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("md5.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test1").toString(), QLatin1String(QCryptographicHash::hash(QByteArray(), QCryptographicHash::Md5).toHex()));
+ QCOMPARE(object->property("test2").toString(), QLatin1String(QCryptographicHash::hash("Hello World", QCryptographicHash::Md5).toHex()));
+
+ delete object;
+}
+
+void tst_qdeclarativeqt::createComponent()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("createComponent.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("incorrectArgCount1").toBool(), true);
+ QCOMPARE(object->property("incorrectArgCount2").toBool(), true);
+ QCOMPARE(object->property("emptyArg").toBool(), true);
+
+ QCOMPARE(object->property("absoluteUrl").toString(), QString("http://www.example.com/test.qml"));
+ QCOMPARE(object->property("relativeUrl").toString(), TEST_FILE("createComponentData.qml").toString());
+
+ delete object;
+}
+
+void tst_qdeclarativeqt::createQmlObject()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("createQmlObject.qml"));
+
+ QString warning1 = "QDeclarativeEngine::createQmlObject():";
+ QString warning2 = " " + TEST_FILE("main.qml").toString() + ":4:1: Duplicate property name";
+ QString warning3 = "QDeclarativeEngine::createQmlObject(): Component is not ready";
+ QString warning4 = "QDeclarativeEngine::createQmlObject():";
+ QString warning5 = " " + TEST_FILE("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));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("incorrectArgCount1").toBool(), true);
+ QCOMPARE(object->property("incorrectArgCount2").toBool(), true);
+ QCOMPARE(object->property("emptyArg").toBool(), true);
+ QCOMPARE(object->property("errors").toBool(), true);
+ QCOMPARE(object->property("noParent").toBool(), true);
+ QCOMPARE(object->property("notReady").toBool(), true);
+ QCOMPARE(object->property("runtimeError").toBool(), true);
+ QCOMPARE(object->property("success").toBool(), true);
+
+ QDeclarativeItem *item = qobject_cast<QDeclarativeItem *>(object);
+ QVERIFY(item != 0);
+ QVERIFY(item->childItems().count() == 1);
+
+ delete object;
+}
+
+void tst_qdeclarativeqt::consoleLog()
+{
+ QTest::ignoreMessage(QtDebugMsg, "completed ok");
+ QTest::ignoreMessage(QtDebugMsg, "completed ok");
+ QDeclarativeComponent component(&engine, TEST_FILE("consoleLog.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ delete object;
+}
+
+QTEST_MAIN(tst_qdeclarativeqt)
+
+#include "tst_qdeclarativeqt.moc"
diff --git a/tests/auto/declarative/qmlgraphicsrepeater/data/intmodel.qml b/tests/auto/declarative/qdeclarativerepeater/data/intmodel.qml
index cf1fb4d..cf1fb4d 100644
--- a/tests/auto/declarative/qmlgraphicsrepeater/data/intmodel.qml
+++ b/tests/auto/declarative/qdeclarativerepeater/data/intmodel.qml
diff --git a/tests/auto/declarative/qmlgraphicsrepeater/data/itemlist.qml b/tests/auto/declarative/qdeclarativerepeater/data/itemlist.qml
index fc6b34c..fc6b34c 100644
--- a/tests/auto/declarative/qmlgraphicsrepeater/data/itemlist.qml
+++ b/tests/auto/declarative/qdeclarativerepeater/data/itemlist.qml
diff --git a/tests/auto/declarative/qmlgraphicsrepeater/data/objlist.qml b/tests/auto/declarative/qdeclarativerepeater/data/objlist.qml
index e6d0acb..e6d0acb 100644
--- a/tests/auto/declarative/qmlgraphicsrepeater/data/objlist.qml
+++ b/tests/auto/declarative/qdeclarativerepeater/data/objlist.qml
diff --git a/tests/auto/declarative/qmlgraphicsrepeater/data/properties.qml b/tests/auto/declarative/qdeclarativerepeater/data/properties.qml
index 550ce8d..550ce8d 100644
--- a/tests/auto/declarative/qmlgraphicsrepeater/data/properties.qml
+++ b/tests/auto/declarative/qdeclarativerepeater/data/properties.qml
diff --git a/tests/auto/declarative/qmlgraphicsrepeater/data/repeater.qml b/tests/auto/declarative/qdeclarativerepeater/data/repeater.qml
index 7d83230..7d83230 100644
--- a/tests/auto/declarative/qmlgraphicsrepeater/data/repeater.qml
+++ b/tests/auto/declarative/qdeclarativerepeater/data/repeater.qml
diff --git a/tests/auto/declarative/qmlgraphicsrepeater/data/repeater2.qml b/tests/auto/declarative/qdeclarativerepeater/data/repeater2.qml
index c3c3260..c3c3260 100644
--- a/tests/auto/declarative/qmlgraphicsrepeater/data/repeater2.qml
+++ b/tests/auto/declarative/qdeclarativerepeater/data/repeater2.qml
diff --git a/tests/auto/declarative/qdeclarativerepeater/qdeclarativerepeater.pro b/tests/auto/declarative/qdeclarativerepeater/qdeclarativerepeater.pro
new file mode 100644
index 0000000..132123a
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativerepeater/qdeclarativerepeater.pro
@@ -0,0 +1,8 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qdeclarativerepeater.cpp
+
+# Define SRCDIR equal to test's source directory
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp b/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp
new file mode 100644
index 0000000..7a97e60
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp
@@ -0,0 +1,385 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+#include <QtTest/QSignalSpy>
+#include <private/qlistmodelinterface_p.h>
+#include <QtDeclarative/qdeclarativeengine.h>
+#include <QtDeclarative/qdeclarativeview.h>
+#include <QtDeclarative/qdeclarativecontext.h>
+#include <private/qdeclarativerepeater_p.h>
+#include <private/qdeclarativetext_p.h>
+
+inline QUrl TEST_FILE(const QString &filename)
+{
+ return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename);
+}
+
+class tst_QDeclarativeRepeater : public QObject
+{
+ Q_OBJECT
+public:
+ tst_QDeclarativeRepeater();
+
+private slots:
+ void numberModel();
+ void objectList();
+ void stringList();
+ void dataModel();
+ void itemModel();
+ void properties();
+
+private:
+ QDeclarativeView *createView();
+ template<typename T>
+ T *findItem(QGraphicsObject *parent, const QString &id);
+};
+
+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;
+};
+
+class TestModel : public QAbstractListModel
+{
+public:
+ enum Roles { Name = Qt::UserRole+1, Number = Qt::UserRole+2 };
+
+ TestModel(QObject *parent=0) : QAbstractListModel(parent) {
+ QHash<int, QByteArray> roles;
+ roles[Name] = "name";
+ roles[Number] = "number";
+ setRoleNames(roles);
+ }
+
+ int rowCount(const QModelIndex &parent=QModelIndex()) const { return list.count(); }
+ QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) 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 count() const { return rowCount(); }
+ QString name(int index) const { return list.at(index).first; }
+ QString number(int index) const { return list.at(index).second; }
+
+ void addItem(const QString &name, const QString &number) {
+ emit beginInsertRows(QModelIndex(), list.count(), list.count());
+ list.append(QPair<QString,QString>(name, number));
+ emit endInsertRows();
+ }
+
+ void 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 removeItem(int index) {
+ emit beginRemoveRows(QModelIndex(), index, index);
+ list.removeAt(index);
+ emit endRemoveRows();
+ }
+
+ void moveItem(int from, int to) {
+ emit beginMoveRows(QModelIndex(), from, from, QModelIndex(), to);
+ list.move(from, to);
+ emit endMoveRows();
+ }
+
+ void modifyItem(int idx, const QString &name, const QString &number) {
+ list[idx] = QPair<QString,QString>(name, number);
+ emit dataChanged(index(idx,0), index(idx,0));
+ }
+
+private:
+ QList<QPair<QString,QString> > list;
+};
+
+
+tst_QDeclarativeRepeater::tst_QDeclarativeRepeater()
+{
+}
+
+void tst_QDeclarativeRepeater::numberModel()
+{
+ QDeclarativeView *canvas = createView();
+
+ QDeclarativeContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testData", 5);
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testObject", testObject);
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/intmodel.qml"));
+ qApp->processEvents();
+
+ QDeclarativeRepeater *repeater = findItem<QDeclarativeRepeater>(canvas->rootObject(), "repeater");
+ QVERIFY(repeater != 0);
+ QCOMPARE(repeater->parentItem()->childItems().count(), 5+1);
+
+ QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
+ QVERIFY(testObject->error() == false);
+
+ delete canvas;
+}
+
+void tst_QDeclarativeRepeater::objectList()
+{
+ QDeclarativeView *canvas = createView();
+
+ QObjectList data;
+ for(int i=0; i<100; i++){
+ data << new QObject();
+ data.back()->setProperty("idx", i);
+ }
+
+ QDeclarativeContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testData", QVariant::fromValue(data));
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/objlist.qml"));
+ qApp->processEvents();
+
+ QDeclarativeRepeater *repeater = findItem<QDeclarativeRepeater>(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);
+}
+
+/*
+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_QDeclarativeRepeater::stringList()
+{
+ QDeclarativeView *canvas = createView();
+
+ QStringList data;
+ data << "One";
+ data << "Two";
+ data << "Three";
+ data << "Four";
+
+ QDeclarativeContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testData", data);
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/repeater.qml"));
+ qApp->processEvents();
+
+ QDeclarativeRepeater *repeater = findItem<QDeclarativeRepeater>(canvas->rootObject(), "repeater");
+ QVERIFY(repeater != 0);
+
+ QDeclarativeItem *container = findItem<QDeclarativeItem>(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) {
+ QDeclarativeText *name = qobject_cast<QDeclarativeText*>(container->childItems().at(i));
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), QLatin1String("Zero"));
+ } else if (i == container->childItems().count() - 2) {
+ // The repeater itself
+ QDeclarativeRepeater *rep = qobject_cast<QDeclarativeRepeater*>(container->childItems().at(i));
+ QCOMPARE(rep, repeater);
+ saw_repeater = true;
+ continue;
+ } else if (i == container->childItems().count() - 1) {
+ QDeclarativeText *name = qobject_cast<QDeclarativeText*>(container->childItems().at(i));
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), QLatin1String("Last"));
+ } else {
+ QDeclarativeText *name = qobject_cast<QDeclarativeText*>(container->childItems().at(i));
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), data.at(i-1));
+ }
+ }
+ QVERIFY(saw_repeater);
+
+ delete canvas;
+}
+
+void tst_QDeclarativeRepeater::dataModel()
+{
+ QDeclarativeView *canvas = createView();
+ QDeclarativeContext *ctxt = canvas->rootContext();
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testObject", testObject);
+
+ TestModel testModel;
+ testModel.addItem("one", "1");
+ testModel.addItem("two", "2");
+ testModel.addItem("three", "3");
+
+ ctxt->setContextProperty("testData", &testModel);
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/repeater2.qml"));
+ qApp->processEvents();
+
+ QDeclarativeRepeater *repeater = findItem<QDeclarativeRepeater>(canvas->rootObject(), "repeater");
+ QVERIFY(repeater != 0);
+
+ QDeclarativeItem *container = findItem<QDeclarativeItem>(canvas->rootObject(), "container");
+ QVERIFY(container != 0);
+
+ QCOMPARE(container->childItems().count(), 4);
+
+ testModel.addItem("four", "4");
+ QCOMPARE(container->childItems().count(), 5);
+
+ testModel.removeItem(2);
+ QCOMPARE(container->childItems().count(), 4);
+}
+
+void tst_QDeclarativeRepeater::itemModel()
+{
+ QDeclarativeView *canvas = createView();
+ QDeclarativeContext *ctxt = canvas->rootContext();
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testObject", testObject);
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/itemlist.qml"));
+ qApp->processEvents();
+
+ QDeclarativeRepeater *repeater = findItem<QDeclarativeRepeater>(canvas->rootObject(), "repeater");
+ QVERIFY(repeater != 0);
+
+ QDeclarativeItem *container = findItem<QDeclarativeItem>(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);
+
+ delete canvas;
+}
+
+void tst_QDeclarativeRepeater::properties()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine, TEST_FILE("/properties.qml"));
+
+ QDeclarativeItem *rootObject = qobject_cast<QDeclarativeItem*>(component.create());
+ QVERIFY(rootObject);
+
+ QDeclarativeRepeater *repeater = findItem<QDeclarativeRepeater>(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 Qt 4.6; Rectangle {}", QUrl::fromLocalFile(""));
+
+ repeater->setDelegate(&rectComponent);
+ QCOMPARE(delegateSpy.count(),1);
+ repeater->setDelegate(&rectComponent);
+ QCOMPARE(delegateSpy.count(),1);
+}
+
+QDeclarativeView *tst_QDeclarativeRepeater::createView()
+{
+ QDeclarativeView *canvas = new QDeclarativeView(0);
+ canvas->setFixedSize(240,320);
+
+ return canvas;
+}
+
+template<typename T>
+T *tst_QDeclarativeRepeater::findItem(QGraphicsObject *parent, const QString &objectName)
+{
+ const QMetaObject &mo = T::staticMetaObject;
+ if (mo.cast(parent) && (objectName.isEmpty() || parent->objectName() == objectName))
+ return static_cast<T*>(parent);
+ for (int i = 0; i < parent->childItems().count(); ++i) {
+ QDeclarativeItem *child = qobject_cast<QDeclarativeItem*>(parent->childItems().at(i));
+ if (!child)
+ continue;
+ QDeclarativeItem *item = findItem<T>(child, objectName);
+ if (item)
+ return static_cast<T*>(item);
+ }
+
+ return 0;
+}
+
+QTEST_MAIN(tst_QDeclarativeRepeater)
+
+#include "tst_qdeclarativerepeater.moc"
diff --git a/tests/auto/declarative/qmlspringfollow/data/springfollow1.qml b/tests/auto/declarative/qdeclarativespringfollow/data/springfollow1.qml
index 959d206..959d206 100644
--- a/tests/auto/declarative/qmlspringfollow/data/springfollow1.qml
+++ b/tests/auto/declarative/qdeclarativespringfollow/data/springfollow1.qml
diff --git a/tests/auto/declarative/qmlspringfollow/data/springfollow2.qml b/tests/auto/declarative/qdeclarativespringfollow/data/springfollow2.qml
index 7c81fb5..7c81fb5 100644
--- a/tests/auto/declarative/qmlspringfollow/data/springfollow2.qml
+++ b/tests/auto/declarative/qdeclarativespringfollow/data/springfollow2.qml
diff --git a/tests/auto/declarative/qmlspringfollow/data/springfollow3.qml b/tests/auto/declarative/qdeclarativespringfollow/data/springfollow3.qml
index 6fec55b..6fec55b 100644
--- a/tests/auto/declarative/qmlspringfollow/data/springfollow3.qml
+++ b/tests/auto/declarative/qdeclarativespringfollow/data/springfollow3.qml
diff --git a/tests/auto/declarative/qdeclarativespringfollow/qdeclarativespringfollow.pro b/tests/auto/declarative/qdeclarativespringfollow/qdeclarativespringfollow.pro
new file mode 100644
index 0000000..61aad0f
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativespringfollow/qdeclarativespringfollow.pro
@@ -0,0 +1,8 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative gui
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qdeclarativespringfollow.cpp
+
+# Define SRCDIR equal to test's source directory
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qdeclarativespringfollow/tst_qdeclarativespringfollow.cpp b/tests/auto/declarative/qdeclarativespringfollow/tst_qdeclarativespringfollow.cpp
new file mode 100644
index 0000000..7a60e78
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativespringfollow/tst_qdeclarativespringfollow.cpp
@@ -0,0 +1,137 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QtDeclarative/qdeclarativeengine.h>
+#include <QtDeclarative/qdeclarativecomponent.h>
+#include <private/qdeclarativespringfollow_p.h>
+#include <private/qdeclarativevaluetype_p.h>
+#include "../../../shared/util.h"
+
+class tst_qdeclarativespringfollow : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qdeclarativespringfollow();
+
+private slots:
+ void defaultValues();
+ void values();
+ void disabled();
+
+private:
+ QDeclarativeEngine engine;
+};
+
+tst_qdeclarativespringfollow::tst_qdeclarativespringfollow()
+{
+}
+
+void tst_qdeclarativespringfollow::defaultValues()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/springfollow1.qml"));
+ QDeclarativeSpringFollow *obj = qobject_cast<QDeclarativeSpringFollow*>(c.create());
+
+ QVERIFY(obj != 0);
+
+ QCOMPARE(obj->sourceValue(), 0.);
+ QCOMPARE(obj->velocity(), 0.);
+ QCOMPARE(obj->spring(), 0.);
+ QCOMPARE(obj->damping(), 0.);
+ QCOMPARE(obj->epsilon(), 0.01);
+ QCOMPARE(obj->modulus(), 0.);
+ QCOMPARE(obj->value(), 0.);
+ QCOMPARE(obj->mass(), 1.);
+ QCOMPARE(obj->enabled(), true);
+ QCOMPARE(obj->inSync(), true);
+
+ delete obj;
+}
+
+void tst_qdeclarativespringfollow::values()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/springfollow2.qml"));
+ QDeclarativeSpringFollow *obj = qobject_cast<QDeclarativeSpringFollow*>(c.create());
+
+ QVERIFY(obj != 0);
+
+ QCOMPARE(obj->sourceValue(), 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->enabled(), true);
+
+ QTRY_COMPARE(obj->value(), 1.44);
+ QTRY_COMPARE(obj->inSync(), true);
+
+ delete obj;
+}
+
+void tst_qdeclarativespringfollow::disabled()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/springfollow3.qml"));
+ QDeclarativeSpringFollow *obj = qobject_cast<QDeclarativeSpringFollow*>(c.create());
+
+ QVERIFY(obj != 0);
+
+ QCOMPARE(obj->sourceValue(), 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->enabled(), false);
+
+ QCOMPARE(obj->value(), 0.0);
+ QCOMPARE(obj->inSync(), false);
+
+ delete obj;
+}
+
+QTEST_MAIN(tst_qdeclarativespringfollow)
+
+#include "tst_qdeclarativespringfollow.moc"
diff --git a/tests/auto/declarative/qmlstates/data/ExtendedRectangle.qml b/tests/auto/declarative/qdeclarativestates/data/ExtendedRectangle.qml
index 8d64663..8d64663 100644
--- a/tests/auto/declarative/qmlstates/data/ExtendedRectangle.qml
+++ b/tests/auto/declarative/qdeclarativestates/data/ExtendedRectangle.qml
diff --git a/tests/auto/declarative/qmlstates/data/anchorChanges.qml b/tests/auto/declarative/qdeclarativestates/data/anchorChanges.qml
index 7dce889..7dce889 100644
--- a/tests/auto/declarative/qmlstates/data/anchorChanges.qml
+++ b/tests/auto/declarative/qdeclarativestates/data/anchorChanges.qml
diff --git a/tests/auto/declarative/qmlstates/data/anchorChanges2.qml b/tests/auto/declarative/qdeclarativestates/data/anchorChanges2.qml
index 545345e..545345e 100644
--- a/tests/auto/declarative/qmlstates/data/anchorChanges2.qml
+++ b/tests/auto/declarative/qdeclarativestates/data/anchorChanges2.qml
diff --git a/tests/auto/declarative/qmlstates/data/anchorChanges3.qml b/tests/auto/declarative/qdeclarativestates/data/anchorChanges3.qml
index 9d5b317..9d5b317 100644
--- a/tests/auto/declarative/qmlstates/data/anchorChanges3.qml
+++ b/tests/auto/declarative/qdeclarativestates/data/anchorChanges3.qml
diff --git a/tests/auto/declarative/qmlstates/data/anchorChanges4.qml b/tests/auto/declarative/qdeclarativestates/data/anchorChanges4.qml
index f128989..f128989 100644
--- a/tests/auto/declarative/qmlstates/data/anchorChanges4.qml
+++ b/tests/auto/declarative/qdeclarativestates/data/anchorChanges4.qml
diff --git a/tests/auto/declarative/qmlstates/data/anchorChanges5.qml b/tests/auto/declarative/qdeclarativestates/data/anchorChanges5.qml
index 4e6d34b..4e6d34b 100644
--- a/tests/auto/declarative/qmlstates/data/anchorChanges5.qml
+++ b/tests/auto/declarative/qdeclarativestates/data/anchorChanges5.qml
diff --git a/tests/auto/declarative/qmlstates/data/autoStateAtStartupRestoreBug.qml b/tests/auto/declarative/qdeclarativestates/data/autoStateAtStartupRestoreBug.qml
index 693a5c5..693a5c5 100644
--- a/tests/auto/declarative/qmlstates/data/autoStateAtStartupRestoreBug.qml
+++ b/tests/auto/declarative/qdeclarativestates/data/autoStateAtStartupRestoreBug.qml
diff --git a/tests/auto/declarative/qmlstates/data/basicBinding.qml b/tests/auto/declarative/qdeclarativestates/data/basicBinding.qml
index 6528113..6528113 100644
--- a/tests/auto/declarative/qmlstates/data/basicBinding.qml
+++ b/tests/auto/declarative/qdeclarativestates/data/basicBinding.qml
diff --git a/tests/auto/declarative/qmlstates/data/basicBinding2.qml b/tests/auto/declarative/qdeclarativestates/data/basicBinding2.qml
index 2e7b4cf..2e7b4cf 100644
--- a/tests/auto/declarative/qmlstates/data/basicBinding2.qml
+++ b/tests/auto/declarative/qdeclarativestates/data/basicBinding2.qml
diff --git a/tests/auto/declarative/qmlstates/data/basicBinding3.qml b/tests/auto/declarative/qdeclarativestates/data/basicBinding3.qml
index a3c47d9..a3c47d9 100644
--- a/tests/auto/declarative/qmlstates/data/basicBinding3.qml
+++ b/tests/auto/declarative/qdeclarativestates/data/basicBinding3.qml
diff --git a/tests/auto/declarative/qmlstates/data/basicBinding4.qml b/tests/auto/declarative/qdeclarativestates/data/basicBinding4.qml
index 1f52d0e..1f52d0e 100644
--- a/tests/auto/declarative/qmlstates/data/basicBinding4.qml
+++ b/tests/auto/declarative/qdeclarativestates/data/basicBinding4.qml
diff --git a/tests/auto/declarative/qmlstates/data/basicChanges.qml b/tests/auto/declarative/qdeclarativestates/data/basicChanges.qml
index 88ea256..88ea256 100644
--- a/tests/auto/declarative/qmlstates/data/basicChanges.qml
+++ b/tests/auto/declarative/qdeclarativestates/data/basicChanges.qml
diff --git a/tests/auto/declarative/qmlstates/data/basicChanges2.qml b/tests/auto/declarative/qdeclarativestates/data/basicChanges2.qml
index 4dd293f..4dd293f 100644
--- a/tests/auto/declarative/qmlstates/data/basicChanges2.qml
+++ b/tests/auto/declarative/qdeclarativestates/data/basicChanges2.qml
diff --git a/tests/auto/declarative/qmlstates/data/basicChanges3.qml b/tests/auto/declarative/qdeclarativestates/data/basicChanges3.qml
index 62ab1d5..62ab1d5 100644
--- a/tests/auto/declarative/qmlstates/data/basicChanges3.qml
+++ b/tests/auto/declarative/qdeclarativestates/data/basicChanges3.qml
diff --git a/tests/auto/declarative/qdeclarativestates/data/basicChanges4.qml b/tests/auto/declarative/qdeclarativestates/data/basicChanges4.qml
new file mode 100644
index 0000000..a373cfc
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativestates/data/basicChanges4.qml
@@ -0,0 +1,19 @@
+import Qt.test 1.0
+import Qt 4.6
+
+MyRectangle {
+ id: rect
+ width: 100; height: 100
+ color: "red"
+
+ states: State {
+ name: "aBlueDay"
+ PropertyChanges {
+ target: rect
+ onPropertyWithNotifyChanged: { rect.color = "blue"; }
+ }
+ }
+
+ Component.onCompleted: rect.state = "aBlueDay"
+}
+
diff --git a/tests/auto/declarative/qmlstates/data/basicExtension.qml b/tests/auto/declarative/qdeclarativestates/data/basicExtension.qml
index 1836f8a..1836f8a 100644
--- a/tests/auto/declarative/qmlstates/data/basicExtension.qml
+++ b/tests/auto/declarative/qdeclarativestates/data/basicExtension.qml
diff --git a/tests/auto/declarative/qmlstates/data/deleting.qml b/tests/auto/declarative/qdeclarativestates/data/deleting.qml
index 3da0b12..3da0b12 100644
--- a/tests/auto/declarative/qmlstates/data/deleting.qml
+++ b/tests/auto/declarative/qdeclarativestates/data/deleting.qml
diff --git a/tests/auto/declarative/qmlstates/data/deletingState.qml b/tests/auto/declarative/qdeclarativestates/data/deletingState.qml
index a5e8ed3..a5e8ed3 100644
--- a/tests/auto/declarative/qmlstates/data/deletingState.qml
+++ b/tests/auto/declarative/qdeclarativestates/data/deletingState.qml
diff --git a/tests/auto/declarative/qmlstates/data/explicit.qml b/tests/auto/declarative/qdeclarativestates/data/explicit.qml
index 7543f84..7543f84 100644
--- a/tests/auto/declarative/qmlstates/data/explicit.qml
+++ b/tests/auto/declarative/qdeclarativestates/data/explicit.qml
diff --git a/tests/auto/declarative/qmlstates/data/fakeExtension.qml b/tests/auto/declarative/qdeclarativestates/data/fakeExtension.qml
index c7975e1..c7975e1 100644
--- a/tests/auto/declarative/qmlstates/data/fakeExtension.qml
+++ b/tests/auto/declarative/qdeclarativestates/data/fakeExtension.qml
diff --git a/tests/auto/declarative/qmlstates/data/illegalTempState.qml b/tests/auto/declarative/qdeclarativestates/data/illegalTempState.qml
index 0dc39ae..0dc39ae 100644
--- a/tests/auto/declarative/qmlstates/data/illegalTempState.qml
+++ b/tests/auto/declarative/qdeclarativestates/data/illegalTempState.qml
diff --git a/tests/auto/declarative/qmlstates/data/legalTempState.qml b/tests/auto/declarative/qdeclarativestates/data/legalTempState.qml
index 9be984c..9be984c 100644
--- a/tests/auto/declarative/qmlstates/data/legalTempState.qml
+++ b/tests/auto/declarative/qdeclarativestates/data/legalTempState.qml
diff --git a/tests/auto/declarative/qmlstates/data/nonExistantProp.qml b/tests/auto/declarative/qdeclarativestates/data/nonExistantProp.qml
index a5dd86a..a5dd86a 100644
--- a/tests/auto/declarative/qmlstates/data/nonExistantProp.qml
+++ b/tests/auto/declarative/qdeclarativestates/data/nonExistantProp.qml
diff --git a/tests/auto/declarative/qmlstates/data/parentChange.qml b/tests/auto/declarative/qdeclarativestates/data/parentChange.qml
index b8c7818..b8c7818 100644
--- a/tests/auto/declarative/qmlstates/data/parentChange.qml
+++ b/tests/auto/declarative/qdeclarativestates/data/parentChange.qml
diff --git a/tests/auto/declarative/qmlstates/data/parentChange2.qml b/tests/auto/declarative/qdeclarativestates/data/parentChange2.qml
index 8b23591..8b23591 100644
--- a/tests/auto/declarative/qmlstates/data/parentChange2.qml
+++ b/tests/auto/declarative/qdeclarativestates/data/parentChange2.qml
diff --git a/tests/auto/declarative/qmlstates/data/parentChange3.qml b/tests/auto/declarative/qdeclarativestates/data/parentChange3.qml
index ddf9268..ddf9268 100644
--- a/tests/auto/declarative/qmlstates/data/parentChange3.qml
+++ b/tests/auto/declarative/qdeclarativestates/data/parentChange3.qml
diff --git a/tests/auto/declarative/qmlstates/data/parentChange4.qml b/tests/auto/declarative/qdeclarativestates/data/parentChange4.qml
index 34d667a..34d667a 100644
--- a/tests/auto/declarative/qmlstates/data/parentChange4.qml
+++ b/tests/auto/declarative/qdeclarativestates/data/parentChange4.qml
diff --git a/tests/auto/declarative/qmlstates/data/parentChange5.qml b/tests/auto/declarative/qdeclarativestates/data/parentChange5.qml
index 56bdd89..56bdd89 100644
--- a/tests/auto/declarative/qmlstates/data/parentChange5.qml
+++ b/tests/auto/declarative/qdeclarativestates/data/parentChange5.qml
diff --git a/tests/auto/declarative/qmlstates/data/propertyErrors.qml b/tests/auto/declarative/qdeclarativestates/data/propertyErrors.qml
index 080e833..080e833 100644
--- a/tests/auto/declarative/qmlstates/data/propertyErrors.qml
+++ b/tests/auto/declarative/qdeclarativestates/data/propertyErrors.qml
diff --git a/tests/auto/declarative/qdeclarativestates/data/reset.qml b/tests/auto/declarative/qdeclarativestates/data/reset.qml
new file mode 100644
index 0000000..a0a2b8c
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativestates/data/reset.qml
@@ -0,0 +1,20 @@
+import Qt 4.6
+
+Rectangle {
+ width: 640
+ height: 480
+ Text {
+ id: theText
+ width: 50
+ wrap: true
+ text: "a text string that is longer than 50 pixels"
+ }
+
+ states: State {
+ name: "state1"
+ PropertyChanges {
+ target: theText
+ width: undefined
+ }
+ }
+}
diff --git a/tests/auto/declarative/qmlstates/data/restoreEntryValues.qml b/tests/auto/declarative/qdeclarativestates/data/restoreEntryValues.qml
index 088c608..088c608 100644
--- a/tests/auto/declarative/qmlstates/data/restoreEntryValues.qml
+++ b/tests/auto/declarative/qdeclarativestates/data/restoreEntryValues.qml
diff --git a/tests/auto/declarative/qmlstates/data/script.qml b/tests/auto/declarative/qdeclarativestates/data/script.qml
index 3c5f33e..3c5f33e 100644
--- a/tests/auto/declarative/qmlstates/data/script.qml
+++ b/tests/auto/declarative/qdeclarativestates/data/script.qml
diff --git a/tests/auto/declarative/qmlstates/data/signalOverride.qml b/tests/auto/declarative/qdeclarativestates/data/signalOverride.qml
index 5ba1566..5ba1566 100644
--- a/tests/auto/declarative/qmlstates/data/signalOverride.qml
+++ b/tests/auto/declarative/qdeclarativestates/data/signalOverride.qml
diff --git a/tests/auto/declarative/qmlstates/data/signalOverride2.qml b/tests/auto/declarative/qdeclarativestates/data/signalOverride2.qml
index 527e165..527e165 100644
--- a/tests/auto/declarative/qmlstates/data/signalOverride2.qml
+++ b/tests/auto/declarative/qdeclarativestates/data/signalOverride2.qml
diff --git a/tests/auto/declarative/qmlstates/data/signalOverrideCrash.qml b/tests/auto/declarative/qdeclarativestates/data/signalOverrideCrash.qml
index 702fa86..702fa86 100644
--- a/tests/auto/declarative/qmlstates/data/signalOverrideCrash.qml
+++ b/tests/auto/declarative/qdeclarativestates/data/signalOverrideCrash.qml
diff --git a/tests/auto/declarative/qdeclarativestates/qdeclarativestates.pro b/tests/auto/declarative/qdeclarativestates/qdeclarativestates.pro
new file mode 100644
index 0000000..f874803
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativestates/qdeclarativestates.pro
@@ -0,0 +1,8 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qdeclarativestates.cpp
+
+# Define SRCDIR equal to test's source directory
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp b/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp
new file mode 100644
index 0000000..8d3ca7a
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp
@@ -0,0 +1,969 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QtDeclarative/qdeclarativeengine.h>
+#include <QtDeclarative/qdeclarativecomponent.h>
+#include <private/qdeclarativeanchors_p_p.h>
+#include <private/qdeclarativerectangle_p.h>
+#include <private/qdeclarativetext_p.h>
+#include <private/qdeclarativepropertychanges_p.h>
+#include <private/qdeclarativestategroup_p.h>
+
+
+class MyRect : public QDeclarativeRectangle
+{
+ 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(); }
+Q_SIGNALS:
+ void didSomething();
+ void oddlyNamedNotifySignal();
+
+private:
+ int m_prop;
+};
+
+QML_DECLARE_TYPE(MyRect)
+
+
+class tst_qdeclarativestates : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qdeclarativestates() {}
+
+private:
+ static QByteArray fullDataPath(const QString &path);
+
+private slots:
+ void initTestCase();
+
+ void basicChanges();
+ void basicExtension();
+ void basicBinding();
+ void signalOverride();
+ void signalOverrideCrash();
+ void parentChange();
+ void parentChangeErrors();
+ void anchorChanges();
+ void anchorChanges2();
+ void anchorChanges3();
+ void anchorChanges4();
+ void anchorChanges5();
+ 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 tst_qdeclarativestates::initTestCase()
+{
+ QML_REGISTER_TYPE(Qt.test, 1, 0, MyRectangle,MyRect);
+}
+
+QByteArray tst_qdeclarativestates::fullDataPath(const QString &path)
+{
+ return QUrl::fromLocalFile(SRCDIR + path).toString().toUtf8();
+}
+
+void tst_qdeclarativestates::basicChanges()
+{
+ QDeclarativeEngine engine;
+
+ {
+ QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/basicChanges.qml");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QCOMPARE(rect->color(),QColor("red"));
+
+ rect->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+
+ rect->setState("");
+ QCOMPARE(rect->color(),QColor("red"));
+ }
+
+ {
+ QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/basicChanges2.qml");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QCOMPARE(rect->color(),QColor("red"));
+
+ rect->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+
+ rect->setState("green");
+ QCOMPARE(rect->color(),QColor("green"));
+
+ rect->setState("");
+ QCOMPARE(rect->color(),QColor("red"));
+
+ rect->setState("green");
+ QCOMPARE(rect->color(),QColor("green"));
+ }
+
+ {
+ QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/basicChanges3.qml");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QCOMPARE(rect->color(),QColor("red"));
+ QCOMPARE(rect->border()->width(),1);
+
+ rect->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+ QCOMPARE(rect->border()->width(),1);
+
+ rect->setState("bordered");
+ QCOMPARE(rect->color(),QColor("red"));
+ QCOMPARE(rect->border()->width(),2);
+
+ rect->setState("");
+ QCOMPARE(rect->color(),QColor("red"));
+ QCOMPARE(rect->border()->width(),1);
+ //### we should be checking that this is an implicit rather than explicit 1 (which currently fails)
+
+ rect->setState("bordered");
+ QCOMPARE(rect->color(),QColor("red"));
+ QCOMPARE(rect->border()->width(),2);
+
+ rect->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+ QCOMPARE(rect->border()->width(),1);
+
+ }
+
+ {
+ // Test basicChanges4.qml can magically connect to propertyWithNotify's notify
+ // signal using 'onPropertyWithNotifyChanged' even though the signal name is
+ // actually 'oddlyNamedNotifySignal'
+
+ QDeclarativeComponent component(&engine, SRCDIR "/data/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::basicExtension()
+{
+ QDeclarativeEngine engine;
+
+ {
+ QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/basicExtension.qml");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QCOMPARE(rect->color(),QColor("red"));
+ QCOMPARE(rect->border()->width(),1);
+
+ rect->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+ QCOMPARE(rect->border()->width(),1);
+
+ rect->setState("bordered");
+ QCOMPARE(rect->color(),QColor("blue"));
+ QCOMPARE(rect->border()->width(),2);
+
+ rect->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+ QCOMPARE(rect->border()->width(),1);
+
+ rect->setState("");
+ QCOMPARE(rect->color(),QColor("red"));
+ QCOMPARE(rect->border()->width(),1);
+
+ rect->setState("bordered");
+ QCOMPARE(rect->color(),QColor("blue"));
+ QCOMPARE(rect->border()->width(),2);
+
+ rect->setState("");
+ QCOMPARE(rect->color(),QColor("red"));
+ QCOMPARE(rect->border()->width(),1);
+ }
+
+ {
+ QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/fakeExtension.qml");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QCOMPARE(rect->color(),QColor("red"));
+
+ rect->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+
+ rect->setState("green");
+ QCOMPARE(rect->color(),QColor("green"));
+
+ rect->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+
+ rect->setState("green");
+ QCOMPARE(rect->color(),QColor("green"));
+
+ rect->setState("");
+ QCOMPARE(rect->color(),QColor("red"));
+
+ rect->setState("green");
+ QCOMPARE(rect->color(),QColor("green"));
+ }
+}
+
+void tst_qdeclarativestates::basicBinding()
+{
+ QDeclarativeEngine engine;
+
+ {
+ QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/basicBinding.qml");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QCOMPARE(rect->color(),QColor("red"));
+
+ rect->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+
+ rect->setState("");
+ QCOMPARE(rect->color(),QColor("red"));
+
+ rect->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+ rect->setProperty("sourceColor", QColor("green"));
+ QCOMPARE(rect->color(),QColor("green"));
+
+ rect->setState("");
+ QCOMPARE(rect->color(),QColor("red"));
+ rect->setProperty("sourceColor", QColor("yellow"));
+ QCOMPARE(rect->color(),QColor("red"));
+
+ rect->setState("blue");
+ QCOMPARE(rect->color(),QColor("yellow"));
+ }
+
+ {
+ QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/basicBinding2.qml");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QCOMPARE(rect->color(),QColor("red"));
+
+ rect->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+
+ rect->setState("");
+ QCOMPARE(rect->color(),QColor("red"));
+
+ rect->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+ rect->setProperty("sourceColor", QColor("green"));
+ QCOMPARE(rect->color(),QColor("blue"));
+
+ rect->setState("");
+ QCOMPARE(rect->color(),QColor("green"));
+ rect->setProperty("sourceColor", QColor("yellow"));
+ QCOMPARE(rect->color(),QColor("yellow"));
+
+ rect->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+
+ rect->setState("");
+ QCOMPARE(rect->color(),QColor("yellow"));
+ }
+
+ {
+ QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/basicBinding3.qml");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QCOMPARE(rect->color(),QColor("red"));
+ rect->setProperty("sourceColor", QColor("green"));
+ QCOMPARE(rect->color(),QColor("green"));
+
+ rect->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"));
+
+ rect->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, SRCDIR "/data/basicBinding4.qml");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QCOMPARE(rect->color(),QColor("red"));
+
+ rect->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+ rect->setProperty("sourceColor", QColor("yellow"));
+ QCOMPARE(rect->color(),QColor("yellow"));
+
+ rect->setState("green");
+ QCOMPARE(rect->color(),QColor("green"));
+ rect->setProperty("sourceColor", QColor("purple"));
+ QCOMPARE(rect->color(),QColor("green"));
+
+ rect->setState("blue");
+ QCOMPARE(rect->color(),QColor("purple"));
+
+ rect->setState("green");
+ QCOMPARE(rect->color(),QColor("green"));
+
+ rect->setState("");
+ QCOMPARE(rect->color(),QColor("red"));
+ }
+}
+
+void tst_qdeclarativestates::signalOverride()
+{
+ QDeclarativeEngine engine;
+
+ {
+ QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/signalOverride.qml");
+ MyRect *rect = qobject_cast<MyRect*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QCOMPARE(rect->color(),QColor("red"));
+ rect->doSomething();
+ QCOMPARE(rect->color(),QColor("blue"));
+
+ rect->setState("green");
+ rect->doSomething();
+ QCOMPARE(rect->color(),QColor("green"));
+ }
+
+ {
+ QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/signalOverride2.qml");
+ MyRect *rect = qobject_cast<MyRect*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QCOMPARE(rect->color(),QColor("white"));
+ rect->doSomething();
+ QCOMPARE(rect->color(),QColor("blue"));
+
+ QDeclarativeRectangle *innerRect = qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("extendedRect"));
+
+ 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, SRCDIR "/data/signalOverrideCrash.qml");
+ MyRect *rect = qobject_cast<MyRect*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ rect->setState("overridden");
+ rect->doSomething();
+}
+
+void tst_qdeclarativestates::parentChange()
+{
+ QDeclarativeEngine engine;
+
+ {
+ QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/parentChange.qml");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QDeclarativeRectangle *innerRect = qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"));
+ QVERIFY(innerRect != 0);
+
+ QDeclarativeListReference list(rect, "states");
+ QDeclarativeState *state = qobject_cast<QDeclarativeState*>(list.at(0));
+ QVERIFY(state != 0);
+
+ qmlExecuteDeferred(state);
+ QDeclarativeParentChange *pChange = qobject_cast<QDeclarativeParentChange*>(state->operationAt(0));
+ QVERIFY(pChange != 0);
+ QDeclarativeItem *nParent = qobject_cast<QDeclarativeItem*>(rect->findChild<QDeclarativeItem*>("NewParent"));
+ QVERIFY(nParent != 0);
+
+ QCOMPARE(pChange->parent(), nParent);
+
+ 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, SRCDIR "/data/parentChange2.qml");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QDeclarativeRectangle *innerRect = qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"));
+ QVERIFY(innerRect != 0);
+
+ rect->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, SRCDIR "/data/parentChange3.qml");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QDeclarativeRectangle *innerRect = qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"));
+ QVERIFY(innerRect != 0);
+
+ rect->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));
+
+ rect->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));
+ }
+}
+
+void tst_qdeclarativestates::parentChangeErrors()
+{
+ QDeclarativeEngine engine;
+
+ {
+ QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/parentChange4.qml");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QDeclarativeRectangle *innerRect = qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"));
+ QVERIFY(innerRect != 0);
+
+ QTest::ignoreMessage(QtWarningMsg, QByteArray("QML ParentChange (" + fullDataPath("/data/parentChange4.qml") + ":25:9) Unable to preserve appearance under non-uniform scale").constData());
+ 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, SRCDIR "/data/parentChange5.qml");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QDeclarativeRectangle *innerRect = qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"));
+ QVERIFY(innerRect != 0);
+
+ QTest::ignoreMessage(QtWarningMsg, QByteArray("QML ParentChange (" + fullDataPath("/data/parentChange5.qml") + ":25:9) Unable to preserve appearance under complex transform").constData());
+ 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, SRCDIR "/data/anchorChanges.qml");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QDeclarativeRectangle *innerRect = qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"));
+ QVERIFY(innerRect != 0);
+
+ QDeclarativeListReference list(rect, "states");
+ QDeclarativeState *state = qobject_cast<QDeclarativeState*>(list.at(0));
+ QVERIFY(state != 0);
+
+ qmlExecuteDeferred(state);
+ QDeclarativeAnchorChanges *aChanges = qobject_cast<QDeclarativeAnchorChanges*>(state->operationAt(0));
+ QVERIFY(aChanges != 0);
+
+ rect->setState("right");
+ QCOMPARE(innerRect->x(), qreal(150));
+ QCOMPARE(aChanges->reset(), QString("left"));
+ QCOMPARE(aChanges->object(), innerRect);
+ QCOMPARE(aChanges->right().item, rect->right().item);
+ QCOMPARE(aChanges->right().anchorLine, rect->right().anchorLine);
+
+ rect->setState("");
+ QCOMPARE(innerRect->x(), qreal(5));
+
+ delete rect;
+}
+
+void tst_qdeclarativestates::anchorChanges2()
+{
+ QDeclarativeEngine engine;
+
+ QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/anchorChanges2.qml");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QDeclarativeRectangle *innerRect = qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"));
+ QVERIFY(innerRect != 0);
+
+ rect->setState("right");
+ QEXPECT_FAIL("", "QTBUG-5338", Continue);
+ QCOMPARE(innerRect->x(), qreal(150));
+
+ rect->setState("");
+ QCOMPARE(innerRect->x(), qreal(5));
+
+ delete rect;
+}
+
+void tst_qdeclarativestates::anchorChanges3()
+{
+ QDeclarativeEngine engine;
+
+ QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/anchorChanges3.qml");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QDeclarativeRectangle *innerRect = qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"));
+ QVERIFY(innerRect != 0);
+
+ QDeclarativeItem *leftGuideline = qobject_cast<QDeclarativeItem*>(rect->findChild<QDeclarativeItem*>("LeftGuideline"));
+ QVERIFY(leftGuideline != 0);
+
+ QDeclarativeItem *bottomGuideline = qobject_cast<QDeclarativeItem*>(rect->findChild<QDeclarativeItem*>("BottomGuideline"));
+ QVERIFY(bottomGuideline != 0);
+
+ QDeclarativeListReference list(rect, "states");
+ QDeclarativeState *state = qobject_cast<QDeclarativeState*>(list.at(0));
+ QVERIFY(state != 0);
+
+ qmlExecuteDeferred(state);
+ QDeclarativeAnchorChanges *aChanges = qobject_cast<QDeclarativeAnchorChanges*>(state->operationAt(0));
+ QVERIFY(aChanges != 0);
+
+ rect->setState("reanchored");
+ QCOMPARE(aChanges->object(), innerRect);
+ QCOMPARE(aChanges->left().item, leftGuideline->left().item);
+ QCOMPARE(aChanges->left().anchorLine, leftGuideline->left().anchorLine);
+ QCOMPARE(aChanges->right().item, rect->right().item);
+ QCOMPARE(aChanges->right().anchorLine, rect->right().anchorLine);
+ QCOMPARE(aChanges->top().item, rect->top().item);
+ QCOMPARE(aChanges->top().anchorLine, rect->top().anchorLine);
+ QCOMPARE(aChanges->bottom().item, bottomGuideline->bottom().item);
+ QCOMPARE(aChanges->bottom().anchorLine, bottomGuideline->bottom().anchorLine);
+
+ QCOMPARE(innerRect->x(), qreal(10));
+ QCOMPARE(innerRect->y(), qreal(0));
+ QCOMPARE(innerRect->width(), qreal(190));
+ QCOMPARE(innerRect->height(), qreal(150));
+
+ rect->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, SRCDIR "/data/anchorChanges4.qml");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QDeclarativeRectangle *innerRect = qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"));
+ QVERIFY(innerRect != 0);
+
+ QDeclarativeItem *leftGuideline = qobject_cast<QDeclarativeItem*>(rect->findChild<QDeclarativeItem*>("LeftGuideline"));
+ QVERIFY(leftGuideline != 0);
+
+ QDeclarativeItem *bottomGuideline = qobject_cast<QDeclarativeItem*>(rect->findChild<QDeclarativeItem*>("BottomGuideline"));
+ QVERIFY(bottomGuideline != 0);
+
+ QDeclarativeListReference list(rect, "states");
+ QDeclarativeState *state = qobject_cast<QDeclarativeState*>(list.at(0));
+ QVERIFY(state != 0);
+
+ qmlExecuteDeferred(state);
+ QDeclarativeAnchorChanges *aChanges = qobject_cast<QDeclarativeAnchorChanges*>(state->operationAt(0));
+ QVERIFY(aChanges != 0);
+
+ rect->setState("reanchored");
+ QCOMPARE(aChanges->object(), innerRect);
+ QCOMPARE(aChanges->horizontalCenter().item, bottomGuideline->horizontalCenter().item);
+ QCOMPARE(aChanges->horizontalCenter().anchorLine, bottomGuideline->horizontalCenter().anchorLine);
+ QCOMPARE(aChanges->verticalCenter().item, leftGuideline->verticalCenter().item);
+ QCOMPARE(aChanges->verticalCenter().anchorLine, leftGuideline->verticalCenter().anchorLine);
+
+ delete rect;
+}
+
+void tst_qdeclarativestates::anchorChanges5()
+{
+ QDeclarativeEngine engine;
+
+ QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/anchorChanges5.qml");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QDeclarativeRectangle *innerRect = qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"));
+ QVERIFY(innerRect != 0);
+
+ QDeclarativeItem *leftGuideline = qobject_cast<QDeclarativeItem*>(rect->findChild<QDeclarativeItem*>("LeftGuideline"));
+ QVERIFY(leftGuideline != 0);
+
+ QDeclarativeItem *bottomGuideline = qobject_cast<QDeclarativeItem*>(rect->findChild<QDeclarativeItem*>("BottomGuideline"));
+ QVERIFY(bottomGuideline != 0);
+
+ QDeclarativeListReference list(rect, "states");
+ QDeclarativeState *state = qobject_cast<QDeclarativeState*>(list.at(0));
+ QVERIFY(state != 0);
+
+ qmlExecuteDeferred(state);
+ QDeclarativeAnchorChanges *aChanges = qobject_cast<QDeclarativeAnchorChanges*>(state->operationAt(0));
+ QVERIFY(aChanges != 0);
+
+ rect->setState("reanchored");
+ QCOMPARE(aChanges->object(), innerRect);
+ QCOMPARE(aChanges->horizontalCenter().item, bottomGuideline->horizontalCenter().item);
+ QCOMPARE(aChanges->horizontalCenter().anchorLine, bottomGuideline->horizontalCenter().anchorLine);
+ QCOMPARE(aChanges->baseline().item, leftGuideline->baseline().item);
+ QCOMPARE(aChanges->baseline().anchorLine, leftGuideline->baseline().anchorLine);
+
+ delete rect;
+}
+
+void tst_qdeclarativestates::script()
+{
+ QDeclarativeEngine engine;
+
+ {
+ QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/script.qml");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QCOMPARE(rect->color(),QColor("red"));
+
+ rect->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+
+ rect->setState("");
+ QCOMPARE(rect->color(),QColor("blue")); // a script isn't reverted
+ }
+}
+
+void tst_qdeclarativestates::restoreEntryValues()
+{
+ QDeclarativeEngine engine;
+
+ QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/restoreEntryValues.qml");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QCOMPARE(rect->color(),QColor("red"));
+
+ rect->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+
+ rect->setState("");
+ QCOMPARE(rect->color(),QColor("blue"));
+}
+
+void tst_qdeclarativestates::explicitChanges()
+{
+ QDeclarativeEngine engine;
+
+ QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/explicit.qml");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ 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"));
+
+ rect->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+
+ rect->setProperty("sourceColor", QColor("green"));
+ QCOMPARE(rect->color(),QColor("blue"));
+
+ rect->setState("");
+ QCOMPARE(rect->color(),QColor("red"));
+ rect->setProperty("sourceColor", QColor("yellow"));
+ QCOMPARE(rect->color(),QColor("red"));
+
+ rect->setState("blue");
+ QCOMPARE(rect->color(),QColor("yellow"));
+}
+
+void tst_qdeclarativestates::propertyErrors()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/propertyErrors.qml");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QCOMPARE(rect->color(),QColor("red"));
+
+ QTest::ignoreMessage(QtWarningMsg, QByteArray("QML PropertyChanges (" + fullDataPath("/data/propertyErrors.qml") + ":8:9) Cannot assign to non-existent property \"colr\"").constData());
+ QTest::ignoreMessage(QtWarningMsg, QByteArray("QML PropertyChanges (" + fullDataPath("/data/propertyErrors.qml") + ":8:9) Cannot assign to read-only property \"wantsFocus\"").constData());
+ rect->setState("blue");
+}
+
+void tst_qdeclarativestates::incorrectRestoreBug()
+{
+ QDeclarativeEngine engine;
+
+ QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/basicChanges.qml");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QCOMPARE(rect->color(),QColor("red"));
+
+ rect->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+
+ rect->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"));
+
+ rect->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+
+ rect->setState("");
+ QCOMPARE(rect->color(),QColor("green"));
+}
+
+void tst_qdeclarativestates::autoStateAtStartupRestoreBug()
+{
+ QDeclarativeEngine engine;
+
+ QDeclarativeComponent component(&engine, SRCDIR "/data/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, SRCDIR "/data/deleting.qml");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ rect->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+ QCOMPARE(rect->radius(),qreal(5));
+
+ rect->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);
+
+ rect->setState("blue");
+ QCOMPARE(rect->color(),QColor("red"));
+ QCOMPARE(rect->radius(),qreal(5));
+
+ delete rect;
+}
+
+void tst_qdeclarativestates::deletingState()
+{
+ QDeclarativeEngine engine;
+
+ QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/deletingState.qml");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(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, SRCDIR "/data/legalTempState.qml");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QTest::ignoreMessage(QtDebugMsg, "entering placed");
+ QTest::ignoreMessage(QtDebugMsg, "entering idle");
+ rect->setState("placed");
+ QCOMPARE(rect->state(), QLatin1String("idle"));
+}
+
+void tst_qdeclarativestates::illegalTempState()
+{
+ QDeclarativeEngine engine;
+
+ QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/illegalTempState.qml");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QTest::ignoreMessage(QtWarningMsg, "Can't apply a state change as part of a state definition. ");
+ rect->setState("placed");
+ QCOMPARE(rect->state(), QLatin1String("placed"));
+}
+
+void tst_qdeclarativestates::nonExistantProperty()
+{
+ QDeclarativeEngine engine;
+
+ QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/nonExistantProp.qml");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QTest::ignoreMessage(QtWarningMsg, QByteArray("QML PropertyChanges (" + fullDataPath("/data/nonExistantProp.qml") + ":9:9) Cannot assign to non-existent property \"colr\"").constData());
+ rect->setState("blue");
+ QCOMPARE(rect->state(), QLatin1String("blue"));
+}
+
+void tst_qdeclarativestates::reset()
+{
+ QDeclarativeEngine engine;
+
+ QDeclarativeComponent c(&engine, SRCDIR "/data/reset.qml");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect != 0);
+
+ QDeclarativeText *text = rect->findChild<QDeclarativeText*>();
+ QVERIFY(text != 0);
+ QCOMPARE(text->width(), qreal(50.));
+ QVERIFY(text->width() < text->height());
+
+ rect->setState("state1");
+
+ QVERIFY(text->width() > 51);
+ QVERIFY(text->width() > text->height());
+}
+
+QTEST_MAIN(tst_qdeclarativestates)
+
+#include "tst_qdeclarativestates.moc"
diff --git a/tests/auto/declarative/qdeclarativestyledtext/qdeclarativestyledtext.pro b/tests/auto/declarative/qdeclarativestyledtext/qdeclarativestyledtext.pro
new file mode 100644
index 0000000..bd4d829
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativestyledtext/qdeclarativestyledtext.pro
@@ -0,0 +1,9 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative
+QT += network
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qdeclarativestyledtext.cpp
+
+# QMAKE_CXXFLAGS = -fprofile-arcs -ftest-coverage
+# LIBS += -lgcov
diff --git a/tests/auto/declarative/qdeclarativestyledtext/tst_qdeclarativestyledtext.cpp b/tests/auto/declarative/qdeclarativestyledtext/tst_qdeclarativestyledtext.cpp
new file mode 100644
index 0000000..7b1293e
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativestyledtext/tst_qdeclarativestyledtext.cpp
@@ -0,0 +1,96 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QtTest/QtTest>
+#include <QtGui/QTextLayout>
+#include <private/qdeclarativestyledtext_p.h>
+
+class tst_qdeclarativestyledtext : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qdeclarativestyledtext()
+ {
+ }
+
+private slots:
+ void textOutput();
+ void textOutput_data();
+};
+
+// For malformed input all we test is that we get the expected text out.
+//
+void tst_qdeclarativestyledtext::textOutput_data()
+{
+ QTest::addColumn<QString>("input");
+ QTest::addColumn<QString>("output");
+
+ QTest::newRow("bold") << "<b>bold</b>" << "bold";
+ QTest::newRow("italic") << "<b>italic</b>" << "italic";
+ QTest::newRow("missing >") << "<b>text</b" << "text";
+ QTest::newRow("missing b>") << "<b>text</" << "text";
+ QTest::newRow("missing /b>") << "<b>text<" << "text";
+ QTest::newRow("missing </b>") << "<b>text" << "text";
+ QTest::newRow("bad nest") << "<b>text <i>italic</b></i>" << "text italic";
+ QTest::newRow("font color") << "<font color=\"red\">red text</font>" << "red text";
+ QTest::newRow("font size") << "<font size=\"1\">text</font>" << "text";
+ QTest::newRow("font empty") << "<font>text</font>" << "text";
+ QTest::newRow("font bad 1") << "<font ezis=\"blah\">text</font>" << "text";
+ QTest::newRow("font bad 2") << "<font size=\"1>text</font>" << "";
+ QTest::newRow("extra close") << "<b>text</b></b>" << "text";
+ QTest::newRow("empty") << "" << "";
+}
+
+void tst_qdeclarativestyledtext::textOutput()
+{
+ QFETCH(QString, input);
+ QFETCH(QString, output);
+
+ QTextLayout layout;
+ QDeclarativeStyledText::parse(input, layout);
+
+ QCOMPARE(layout.text(), output);
+}
+
+
+QTEST_MAIN(tst_qdeclarativestyledtext)
+
+#include "tst_qdeclarativestyledtext.moc"
diff --git a/tests/auto/declarative/qdeclarativesystempalette/qdeclarativesystempalette.pro b/tests/auto/declarative/qdeclarativesystempalette/qdeclarativesystempalette.pro
new file mode 100644
index 0000000..0781774
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativesystempalette/qdeclarativesystempalette.pro
@@ -0,0 +1,5 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative gui
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qdeclarativesystempalette.cpp
diff --git a/tests/auto/declarative/qdeclarativesystempalette/tst_qdeclarativesystempalette.cpp b/tests/auto/declarative/qdeclarativesystempalette/tst_qdeclarativesystempalette.cpp
new file mode 100644
index 0000000..5c93952
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativesystempalette/tst_qdeclarativesystempalette.cpp
@@ -0,0 +1,187 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+#include <QDebug>
+#include <QtDeclarative/qdeclarativeengine.h>
+#include <QtDeclarative/qdeclarativecomponent.h>
+#include <private/qdeclarativesystempalette_p.h>
+#include <qpalette.h>
+#include "../../../shared/util.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 Qt 4.6\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 Qt 4.6\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 Qt 4.6\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 Qt 4.6\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/declarative/qdeclarativetext/qdeclarativetext.pro b/tests/auto/declarative/qdeclarativetext/qdeclarativetext.pro
new file mode 100644
index 0000000..8b4b4d1
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetext/qdeclarativetext.pro
@@ -0,0 +1,5 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative gui
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qdeclarativetext.cpp
diff --git a/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp b/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp
new file mode 100644
index 0000000..bbbbd83
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp
@@ -0,0 +1,844 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QTextDocument>
+#include <QtDeclarative/qdeclarativeengine.h>
+#include <QtDeclarative/qdeclarativecomponent.h>
+#include <private/qdeclarativetext_p.h>
+#include <private/qdeclarativevaluetype_p.h>
+#include <QFontMetrics>
+#include <QGraphicsSceneMouseEvent>
+#include <qmath.h>
+
+class tst_qdeclarativetext : public QObject
+
+{
+ Q_OBJECT
+public:
+ tst_qdeclarativetext();
+
+private slots:
+ void text();
+ void width();
+ void wrap();
+ void elide();
+ void textFormat();
+
+ // ### these tests may be trivial
+ void horizontalAlignment();
+ 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();
+
+private:
+ QStringList standard;
+ QStringList richText;
+
+ QStringList horizontalAlignmentmentStrings;
+ QStringList verticalAlignmentmentStrings;
+
+ QList<Qt::Alignment> verticalAlignmentments;
+ QList<Qt::Alignment> horizontalAlignmentments;
+
+ QStringList styleStrings;
+ QList<QDeclarativeText::TextStyle> styles;
+
+ QStringList colorStrings;
+
+ QDeclarativeEngine engine;
+};
+
+tst_qdeclarativetext::tst_qdeclarativetext()
+{
+ 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 << QDeclarativeText::Normal
+ << QDeclarativeText::Outline
+ << QDeclarativeText::Raised
+ << QDeclarativeText::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";
+ //
+}
+
+void tst_qdeclarativetext::text()
+{
+ {
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData("import Qt 4.6\nText { text: \"\" }", QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(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 Qt 4.6\nText { text: \"" + standard.at(i) + "\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE(textObject->text(), standard.at(i));
+ QVERIFY(textObject->width() > 0);
+ }
+
+ for (int i = 0; i < richText.size(); i++)
+ {
+ QString componentStr = "import Qt 4.6\nText { text: \"" + richText.at(i) + "\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QString expected = richText.at(i);
+ QCOMPARE(textObject->text(), expected.replace("\\\"", "\""));
+ QVERIFY(textObject->width() > 0);
+ }
+}
+
+void tst_qdeclarativetext::width()
+{
+ // uses Font metrics to find the width for standard and document to find the width for rich
+ {
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData("import Qt 4.6\nText { text: \"\" }", QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE(textObject->width(), 0.);
+ }
+
+ for (int i = 0; i < standard.size(); i++)
+ {
+ QVERIFY(!Qt::mightBeRichText(standard.at(i))); // self-test
+
+ QFont f;
+ QFontMetricsF fm(f);
+ qreal metricWidth = fm.size(Qt::TextExpandTabs && Qt::TextShowMnemonic, standard.at(i)).width();
+ metricWidth = qCeil(metricWidth);
+
+ QString componentStr = "import Qt 4.6\nText { text: \"" + standard.at(i) + "\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE(textObject->width(), qreal(metricWidth));
+ QVERIFY(textObject->textFormat() == QDeclarativeText::AutoText); // setting text doesn't change format
+ }
+
+ for (int i = 0; i < richText.size(); i++)
+ {
+ QVERIFY(Qt::mightBeRichText(richText.at(i))); // self-test
+
+ QTextDocument document;
+ document.setHtml(richText.at(i));
+ document.setDocumentMargin(0);
+
+ int documentWidth = document.idealWidth();
+
+ QString componentStr = "import Qt 4.6\nText { text: \"" + richText.at(i) + "\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE(textObject->width(), qreal(documentWidth));
+ QVERIFY(textObject->textFormat() == QDeclarativeText::AutoText); // setting text doesn't change format
+ }
+}
+
+void tst_qdeclarativetext::wrap()
+{
+ int textHeight = 0;
+ // for specified width and wrap set true
+ {
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData("import Qt 4.6\nText { text: \"Hello\"; wrap: true; width: 300 }", QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+ textHeight = textObject->height();
+
+ QVERIFY(textObject != 0);
+ QVERIFY(textObject->wrap() == true);
+ QCOMPARE(textObject->width(), 300.);
+ }
+
+ for (int i = 0; i < standard.size(); i++)
+ {
+ QString componentStr = "import Qt 4.6\nText { wrap: true; width: 30; text: \"" + standard.at(i) + "\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE(textObject->width(), 30.);
+ QVERIFY(textObject->height() > textHeight);
+
+ int oldHeight = textObject->height();
+ textObject->setWidth(100);
+ QVERIFY(textObject->height() < oldHeight);
+ }
+
+ for (int i = 0; i < richText.size(); i++)
+ {
+ QString componentStr = "import Qt 4.6\nText { wrap: true; width: 30; text: \"" + richText.at(i) + "\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE(textObject->width(), 30.);
+ QVERIFY(textObject->height() > textHeight);
+ }
+
+}
+
+void tst_qdeclarativetext::elide()
+{
+ for (QDeclarativeText::TextElideMode m = QDeclarativeText::ElideLeft; m<=QDeclarativeText::ElideNone; m=QDeclarativeText::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 Qt 4.6\nText { text: \"\"; "+elide+" width: 100 }").toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QCOMPARE(textObject->elideMode(), m);
+ QCOMPARE(textObject->width(), 100.);
+ }
+
+ for (int i = 0; i < standard.size(); i++)
+ {
+ QString componentStr = "import Qt 4.6\nText { "+elide+" width: 100; text: \"" + standard.at(i) + "\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QCOMPARE(textObject->elideMode(), m);
+ QCOMPARE(textObject->width(), 100.);
+ }
+
+ // richtext - does nothing
+ for (int i = 0; i < richText.size(); i++)
+ {
+ QString componentStr = "import Qt 4.6\nText { "+elide+" width: 100; text: \"" + richText.at(i) + "\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QCOMPARE(textObject->elideMode(), m);
+ QCOMPARE(textObject->width(), 100.);
+ }
+ }
+}
+
+void tst_qdeclarativetext::textFormat()
+{
+ {
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData("import Qt 4.6\nText { text: \"Hello\"; textFormat: Text.RichText }", QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QVERIFY(textObject->textFormat() == QDeclarativeText::RichText);
+ }
+ {
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData("import Qt 4.6\nText { text: \"<b>Hello</b>\"; textFormat: Text.PlainText }", QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QVERIFY(textObject->textFormat() == QDeclarativeText::PlainText);
+ }
+}
+
+//the alignment tests may be trivial o.oa
+void tst_qdeclarativetext::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 Qt 4.6\nText { horizontalAlignment: \"" + horizontalAlignmentmentStrings.at(j) + "\"; text: \"" + standard.at(i) + "\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QCOMPARE((int)textObject->hAlign(), (int)horizontalAlignmentments.at(j));
+ }
+ }
+
+ for (int i = 0; i < richText.size(); i++)
+ {
+ for (int j=0; j < horizontalAlignmentmentStrings.size(); j++)
+ {
+ QString componentStr = "import Qt 4.6\nText { horizontalAlignment: \"" + horizontalAlignmentmentStrings.at(j) + "\"; text: \"" + richText.at(i) + "\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QCOMPARE((int)textObject->hAlign(), (int)horizontalAlignmentments.at(j));
+ }
+ }
+
+}
+
+void tst_qdeclarativetext::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 Qt 4.6\nText { verticalAlignment: \"" + verticalAlignmentmentStrings.at(j) + "\"; text: \"" + standard.at(i) + "\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE((int)textObject->vAlign(), (int)verticalAlignmentments.at(j));
+ }
+ }
+
+ for (int i = 0; i < richText.size(); i++)
+ {
+ for (int j=0; j < verticalAlignmentmentStrings.size(); j++)
+ {
+ QString componentStr = "import Qt 4.6\nText { verticalAlignment: \"" + verticalAlignmentmentStrings.at(j) + "\"; text: \"" + richText.at(i) + "\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE((int)textObject->vAlign(), (int)verticalAlignmentments.at(j));
+ }
+ }
+
+}
+
+void tst_qdeclarativetext::font()
+{
+ //test size, then bold, then italic, then family
+ {
+ QString componentStr = "import Qt 4.6\nText { font.pointSize: 40; text: \"Hello World\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QCOMPARE(textObject->font().pointSize(), 40);
+ QCOMPARE(textObject->font().bold(), false);
+ QCOMPARE(textObject->font().italic(), false);
+ }
+
+ {
+ QString componentStr = "import Qt 4.6\nText { font.pixelSize: 40; text: \"Hello World\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QCOMPARE(textObject->font().pixelSize(), 40);
+ QCOMPARE(textObject->font().bold(), false);
+ QCOMPARE(textObject->font().italic(), false);
+ }
+
+ {
+ QString componentStr = "import Qt 4.6\nText { font.bold: true; text: \"Hello World\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QCOMPARE(textObject->font().bold(), true);
+ QCOMPARE(textObject->font().italic(), false);
+ }
+
+ {
+ QString componentStr = "import Qt 4.6\nText { font.italic: true; text: \"Hello World\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QCOMPARE(textObject->font().italic(), true);
+ QCOMPARE(textObject->font().bold(), false);
+ }
+
+ {
+ QString componentStr = "import Qt 4.6\nText { font.family: \"Helvetica\"; text: \"Hello World\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QCOMPARE(textObject->font().family(), QString("Helvetica"));
+ QCOMPARE(textObject->font().bold(), false);
+ QCOMPARE(textObject->font().italic(), false);
+ }
+
+ {
+ QString componentStr = "import Qt 4.6\nText { font.family: \"\"; text: \"Hello World\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QCOMPARE(textObject->font().family(), QString(""));
+ }
+}
+
+void tst_qdeclarativetext::style()
+{
+ //test style
+ for (int i = 0; i < styles.size(); i++)
+ {
+ QString componentStr = "import Qt 4.6\nText { style: \"" + styleStrings.at(i) + "\"; styleColor: \"white\"; text: \"Hello World\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QCOMPARE((int)textObject->style(), (int)styles.at(i));
+ QCOMPARE(textObject->styleColor(), QColor("white"));
+ }
+}
+
+void tst_qdeclarativetext::color()
+{
+ //test style
+ for (int i = 0; i < colorStrings.size(); i++)
+ {
+ QString componentStr = "import Qt 4.6\nText { color: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QCOMPARE(textObject->color(), QColor(colorStrings.at(i)));
+ QCOMPARE(textObject->styleColor(), QColor());
+ }
+
+ for (int i = 0; i < colorStrings.size(); i++)
+ {
+ QString componentStr = "import Qt 4.6\nText { styleColor: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QCOMPARE(textObject->styleColor(), QColor(colorStrings.at(i)));
+ // default color to black?
+ QCOMPARE(textObject->color(), QColor("black"));
+ }
+
+ for (int i = 0; i < colorStrings.size(); i++)
+ {
+ for (int j = 0; j < colorStrings.size(); j++)
+ {
+ QString componentStr = "import Qt 4.6\nText { color: \"" + colorStrings.at(i) + "\"; styleColor: \"" + colorStrings.at(j) + "\"; text: \"Hello World\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QCOMPARE(textObject->color(), QColor(colorStrings.at(i)));
+ QCOMPARE(textObject->styleColor(), QColor(colorStrings.at(j)));
+ }
+ }
+ {
+ QString colorStr = "#AA001234";
+ QColor testColor("#001234");
+ testColor.setAlpha(170);
+
+ QString componentStr = "import Qt 4.6\nText { color: \"" + colorStr + "\"; text: \"Hello World\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QCOMPARE(textObject->color(), testColor);
+ }
+}
+
+void tst_qdeclarativetext::smooth()
+{
+ for (int i = 0; i < standard.size(); i++)
+ {
+ {
+ QString componentStr = "import Qt 4.6\nText { smooth: true; text: \"" + standard.at(i) + "\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+ QCOMPARE(textObject->smooth(), true);
+ }
+ {
+ QString componentStr = "import Qt 4.6\nText { text: \"" + standard.at(i) + "\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+ QCOMPARE(textObject->smooth(), false);
+ }
+ }
+ for (int i = 0; i < richText.size(); i++)
+ {
+ {
+ QString componentStr = "import Qt 4.6\nText { smooth: true; text: \"" + richText.at(i) + "\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+ QCOMPARE(textObject->smooth(), true);
+ }
+ {
+ QString componentStr = "import Qt 4.6\nText { text: \"" + richText.at(i) + "\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+ QCOMPARE(textObject->smooth(), false);
+ }
+ }
+}
+
+void tst_qdeclarativetext::weight()
+{
+ {
+ QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE((int)textObject->font().weight(), (int)QDeclarativeFontValueType::Normal);
+ }
+ {
+ QString componentStr = "import Qt 4.6\nText { font.weight: \"Bold\"; text: \"Hello world!\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE((int)textObject->font().weight(), (int)QDeclarativeFontValueType::Bold);
+ }
+}
+
+void tst_qdeclarativetext::underline()
+{
+ {
+ QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE(textObject->font().underline(), false);
+ }
+ {
+ QString componentStr = "import Qt 4.6\nText { font.underline: true; text: \"Hello world!\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE(textObject->font().underline(), true);
+ }
+}
+
+void tst_qdeclarativetext::overline()
+{
+ {
+ QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE(textObject->font().overline(), false);
+ }
+ {
+ QString componentStr = "import Qt 4.6\nText { font.overline: true; text: \"Hello world!\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE(textObject->font().overline(), true);
+ }
+}
+
+void tst_qdeclarativetext::strikeout()
+{
+ {
+ QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE(textObject->font().strikeOut(), false);
+ }
+ {
+ QString componentStr = "import Qt 4.6\nText { font.strikeout: true; text: \"Hello world!\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE(textObject->font().strikeOut(), true);
+ }
+}
+
+void tst_qdeclarativetext::capitalization()
+{
+ {
+ QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE((int)textObject->font().capitalization(), (int)QDeclarativeFontValueType::MixedCase);
+ }
+ {
+ QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\"; font.capitalization: \"AllUppercase\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE((int)textObject->font().capitalization(), (int)QDeclarativeFontValueType::AllUppercase);
+ }
+ {
+ QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\"; font.capitalization: \"AllLowercase\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE((int)textObject->font().capitalization(), (int)QDeclarativeFontValueType::AllLowercase);
+ }
+ {
+ QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\"; font.capitalization: \"SmallCaps\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE((int)textObject->font().capitalization(), (int)QDeclarativeFontValueType::SmallCaps);
+ }
+ {
+ QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\"; font.capitalization: \"Capitalize\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE((int)textObject->font().capitalization(), (int)QDeclarativeFontValueType::Capitalize);
+ }
+}
+
+void tst_qdeclarativetext::letterSpacing()
+{
+ {
+ QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE(textObject->font().letterSpacing(), 0.0);
+ }
+ {
+ QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\"; font.letterSpacing: -50 }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE(textObject->font().letterSpacing(), -50.);
+ }
+ {
+ QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\"; font.letterSpacing: 200 }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE(textObject->font().letterSpacing(), 200.);
+ }
+}
+
+void tst_qdeclarativetext::wordSpacing()
+{
+ {
+ QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE(textObject->font().wordSpacing(), 0.0);
+ }
+ {
+ QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\"; font.wordSpacing: -50 }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE(textObject->font().wordSpacing(), -50.);
+ }
+ {
+ QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\"; font.wordSpacing: 200 }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE(textObject->font().wordSpacing(), 200.);
+ }
+}
+
+class EventSender : public QGraphicsItem
+{
+public:
+ void sendEvent(QEvent *event) { sceneEvent(event); }
+};
+
+class LinkTest : public QObject
+{
+ Q_OBJECT
+public:
+ LinkTest() {}
+
+ QString link;
+
+public slots:
+ void linkClicked(QString l) { link = l; }
+};
+
+void tst_qdeclarativetext::clickLink()
+{
+ {
+ QString componentStr = "import Qt 4.6\nText { text: \"<a href=\\\"http://qt.nokia.com\\\">Hello world!</a>\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+
+ LinkTest test;
+ QObject::connect(textObject, SIGNAL(linkActivated(QString)), &test, SLOT(linkClicked(QString)));
+
+ {
+ QGraphicsSceneMouseEvent me(QEvent::GraphicsSceneMousePress);
+ me.setPos(QPointF(textObject->x()/2, textObject->y()/2));
+ me.setButton(Qt::LeftButton);
+ static_cast<EventSender*>(static_cast<QGraphicsItem*>(textObject))->sendEvent(&me);
+ }
+
+ {
+ QGraphicsSceneMouseEvent me(QEvent::GraphicsSceneMouseRelease);
+ me.setPos(QPointF(textObject->x()/2, textObject->y()/2));
+ me.setButton(Qt::LeftButton);
+ static_cast<EventSender*>(static_cast<QGraphicsItem*>(textObject))->sendEvent(&me);
+ }
+
+ QCOMPARE(test.link, QLatin1String("http://qt.nokia.com"));
+ }
+}
+
+QTEST_MAIN(tst_qdeclarativetext)
+
+#include "tst_qdeclarativetext.moc"
diff --git a/tests/auto/declarative/qmlgraphicstextedit/data/cursorTest.qml b/tests/auto/declarative/qdeclarativetextedit/data/cursorTest.qml
index e5df8f1..e5df8f1 100644
--- a/tests/auto/declarative/qmlgraphicstextedit/data/cursorTest.qml
+++ b/tests/auto/declarative/qdeclarativetextedit/data/cursorTest.qml
diff --git a/tests/auto/declarative/qmlgraphicstextedit/data/http/ErrItem.qml b/tests/auto/declarative/qdeclarativetextedit/data/http/ErrItem.qml
index 34b3883..34b3883 100644
--- a/tests/auto/declarative/qmlgraphicstextedit/data/http/ErrItem.qml
+++ b/tests/auto/declarative/qdeclarativetextedit/data/http/ErrItem.qml
diff --git a/tests/auto/declarative/qmlgraphicstextedit/data/http/NormItem.qml b/tests/auto/declarative/qdeclarativetextedit/data/http/NormItem.qml
index 718cb71..718cb71 100644
--- a/tests/auto/declarative/qmlgraphicstextedit/data/http/NormItem.qml
+++ b/tests/auto/declarative/qdeclarativetextedit/data/http/NormItem.qml
diff --git a/tests/auto/declarative/qmlgraphicstextedit/data/http/cursorHttpTest.qml b/tests/auto/declarative/qdeclarativetextedit/data/http/cursorHttpTest.qml
index 3c31e11..3c31e11 100644
--- a/tests/auto/declarative/qmlgraphicstextedit/data/http/cursorHttpTest.qml
+++ b/tests/auto/declarative/qdeclarativetextedit/data/http/cursorHttpTest.qml
diff --git a/tests/auto/declarative/qmlgraphicstextedit/data/http/cursorHttpTestFail1.qml b/tests/auto/declarative/qdeclarativetextedit/data/http/cursorHttpTestFail1.qml
index a44aec2..a44aec2 100644
--- a/tests/auto/declarative/qmlgraphicstextedit/data/http/cursorHttpTestFail1.qml
+++ b/tests/auto/declarative/qdeclarativetextedit/data/http/cursorHttpTestFail1.qml
diff --git a/tests/auto/declarative/qmlgraphicstextedit/data/http/cursorHttpTestFail2.qml b/tests/auto/declarative/qdeclarativetextedit/data/http/cursorHttpTestFail2.qml
index 57d3e47..57d3e47 100644
--- a/tests/auto/declarative/qmlgraphicstextedit/data/http/cursorHttpTestFail2.qml
+++ b/tests/auto/declarative/qdeclarativetextedit/data/http/cursorHttpTestFail2.qml
diff --git a/tests/auto/declarative/qmlgraphicstextedit/data/http/cursorHttpTestPass.qml b/tests/auto/declarative/qdeclarativetextedit/data/http/cursorHttpTestPass.qml
index a44e867..a44e867 100644
--- a/tests/auto/declarative/qmlgraphicstextedit/data/http/cursorHttpTestPass.qml
+++ b/tests/auto/declarative/qdeclarativetextedit/data/http/cursorHttpTestPass.qml
diff --git a/tests/auto/declarative/qmlgraphicstextedit/data/httpfail/FailItem.qml b/tests/auto/declarative/qdeclarativetextedit/data/httpfail/FailItem.qml
index ddbf526..ddbf526 100644
--- a/tests/auto/declarative/qmlgraphicstextedit/data/httpfail/FailItem.qml
+++ b/tests/auto/declarative/qdeclarativetextedit/data/httpfail/FailItem.qml
diff --git a/tests/auto/declarative/qmlgraphicstextedit/data/httpslow/WaitItem.qml b/tests/auto/declarative/qdeclarativetextedit/data/httpslow/WaitItem.qml
index ddbf526..ddbf526 100644
--- a/tests/auto/declarative/qmlgraphicstextedit/data/httpslow/WaitItem.qml
+++ b/tests/auto/declarative/qdeclarativetextedit/data/httpslow/WaitItem.qml
diff --git a/tests/auto/declarative/qmlgraphicstextedit/data/inputmethodhints.qml b/tests/auto/declarative/qdeclarativetextedit/data/inputmethodhints.qml
index c3d4c16..c3d4c16 100644
--- a/tests/auto/declarative/qmlgraphicstextedit/data/inputmethodhints.qml
+++ b/tests/auto/declarative/qdeclarativetextedit/data/inputmethodhints.qml
diff --git a/tests/auto/declarative/qmlgraphicstextedit/data/navigation.qml b/tests/auto/declarative/qdeclarativetextedit/data/navigation.qml
index 8d7dbbc..8d7dbbc 100644
--- a/tests/auto/declarative/qmlgraphicstextedit/data/navigation.qml
+++ b/tests/auto/declarative/qdeclarativetextedit/data/navigation.qml
diff --git a/tests/auto/declarative/qmlgraphicstextedit/data/readOnly.qml b/tests/auto/declarative/qdeclarativetextedit/data/readOnly.qml
index 103a627..103a627 100644
--- a/tests/auto/declarative/qmlgraphicstextedit/data/readOnly.qml
+++ b/tests/auto/declarative/qdeclarativetextedit/data/readOnly.qml
diff --git a/tests/auto/declarative/qdeclarativetextedit/qdeclarativetextedit.pro b/tests/auto/declarative/qdeclarativetextedit/qdeclarativetextedit.pro
new file mode 100644
index 0000000..2228f11
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetextedit/qdeclarativetextedit.pro
@@ -0,0 +1,9 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative gui network
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qdeclarativetextedit.cpp ../shared/testhttpserver.cpp
+HEADERS += ../shared/testhttpserver.h
+
+# Define SRCDIR equal to test's source directory
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
new file mode 100644
index 0000000..b677fec
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
@@ -0,0 +1,791 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include "../../../shared/util.h"
+#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 <private/qdeclarativetextedit_p.h>
+#include <QFontMetrics>
+#include <QDeclarativeView>
+#include <QStyle>
+#include <QInputContext>
+
+class tst_qdeclarativetextedit : public QObject
+
+{
+ Q_OBJECT
+public:
+ tst_qdeclarativetextedit();
+
+private slots:
+ void text();
+ void width();
+ void wrap();
+ void textFormat();
+
+ // ### these tests may be trivial
+ void hAlign();
+ void vAlign();
+ void font();
+ void color();
+ void textMargin();
+ void persistentSelection();
+ void focusOnPress();
+ void selection();
+ void inputMethodHints();
+
+ void cursorDelegate();
+ void delegateLoading();
+ void navigation();
+ void readOnly();
+ void sendRequestSoftwareInputPanelEvent();
+
+private:
+ void simulateKey(QDeclarativeView *, int key);
+ QDeclarativeView *createView(const QString &filename);
+
+ QStringList standard;
+ QStringList richText;
+
+ QStringList hAlignmentStrings;
+ QStringList vAlignmentStrings;
+
+ QList<Qt::Alignment> vAlignments;
+ QList<Qt::Alignment> hAlignments;
+
+ QStringList colorStrings;
+
+ QDeclarativeEngine engine;
+};
+
+tst_qdeclarativetextedit::tst_qdeclarativetextedit()
+{
+ 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>";
+
+ 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_qdeclarativetextedit::text()
+{
+ {
+ QDeclarativeComponent texteditComponent(&engine);
+ texteditComponent.setData("import Qt 4.6\nTextEdit { text: \"\" }", QUrl());
+ QDeclarativeTextEdit *textEditObject = qobject_cast<QDeclarativeTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->text(), QString(""));
+ }
+
+ for (int i = 0; i < standard.size(); i++)
+ {
+ QString componentStr = "import Qt 4.6\nTextEdit { text: \"" + standard.at(i) + "\" }";
+ QDeclarativeComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QDeclarativeTextEdit *textEditObject = qobject_cast<QDeclarativeTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->text(), standard.at(i));
+ }
+
+ for (int i = 0; i < richText.size(); i++)
+ {
+ QString componentStr = "import Qt 4.6\nTextEdit { text: \"" + richText.at(i) + "\" }";
+ QDeclarativeComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QDeclarativeTextEdit *textEditObject = qobject_cast<QDeclarativeTextEdit*>(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());
+ }
+}
+
+void tst_qdeclarativetextedit::width()
+{
+ // uses Font metrics to find the width for standard and document to find the width for rich
+ {
+ QDeclarativeComponent texteditComponent(&engine);
+ texteditComponent.setData("import Qt 4.6\nTextEdit { text: \"\" }", QUrl());
+ QDeclarativeTextEdit *textEditObject = qobject_cast<QDeclarativeTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->width(), 1.);//+1 for cursor
+ }
+
+ for (int i = 0; i < standard.size(); i++)
+ {
+ QFont f;
+ QFontMetricsF fm(f);
+ qreal metricWidth = fm.size(Qt::TextExpandTabs && Qt::TextShowMnemonic, standard.at(i)).width();
+ metricWidth = floor(metricWidth);
+
+ QString componentStr = "import Qt 4.6\nTextEdit { text: \"" + standard.at(i) + "\" }";
+ QDeclarativeComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QDeclarativeTextEdit *textEditObject = qobject_cast<QDeclarativeTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->width(), qreal(metricWidth + 1 + 3));//+3 is the current way of accounting for space between cursor and last character.
+ }
+
+ for (int i = 0; i < richText.size(); i++)
+ {
+ QTextDocument document;
+ document.setHtml(richText.at(i));
+ document.setDocumentMargin(0);
+
+ int documentWidth = document.idealWidth();
+
+ QString componentStr = "import Qt 4.6\nTextEdit { text: \"" + richText.at(i) + "\" }";
+ QDeclarativeComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QDeclarativeTextEdit *textEditObject = qobject_cast<QDeclarativeTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->width(), qreal(documentWidth + 1 + 3));
+ }
+}
+
+void tst_qdeclarativetextedit::wrap()
+{
+ // for specified width and wrap set true
+ {
+ QDeclarativeComponent texteditComponent(&engine);
+ texteditComponent.setData("import Qt 4.6\nTextEdit { text: \"\"; wrap: true; width: 300 }", QUrl());
+ QDeclarativeTextEdit *textEditObject = qobject_cast<QDeclarativeTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->width(), 300.);
+ }
+
+ for (int i = 0; i < standard.size(); i++)
+ {
+ QString componentStr = "import Qt 4.6\nTextEdit { wrap: true; width: 300; text: \"" + standard.at(i) + "\" }";
+ QDeclarativeComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QDeclarativeTextEdit *textEditObject = qobject_cast<QDeclarativeTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->width(), 300.);
+ }
+
+ for (int i = 0; i < richText.size(); i++)
+ {
+ QString componentStr = "import Qt 4.6\nTextEdit { wrap: true; width: 300; text: \"" + richText.at(i) + "\" }";
+ QDeclarativeComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QDeclarativeTextEdit *textEditObject = qobject_cast<QDeclarativeTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->width(), 300.);
+ }
+
+}
+
+void tst_qdeclarativetextedit::textFormat()
+{
+ {
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData("import Qt 4.6\nTextEdit { text: \"Hello\"; textFormat: Text.RichText }", QUrl::fromLocalFile(""));
+ QDeclarativeTextEdit *textObject = qobject_cast<QDeclarativeTextEdit*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QVERIFY(textObject->textFormat() == QDeclarativeTextEdit::RichText);
+ }
+ {
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData("import Qt 4.6\nTextEdit { text: \"<b>Hello</b>\"; textFormat: Text.PlainText }", QUrl::fromLocalFile(""));
+ QDeclarativeTextEdit *textObject = qobject_cast<QDeclarativeTextEdit*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QVERIFY(textObject->textFormat() == QDeclarativeTextEdit::PlainText);
+ }
+}
+
+//the alignment tests may be trivial o.oa
+void tst_qdeclarativetextedit::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 Qt 4.6\nTextEdit { horizontalAlignment: \"" + hAlignmentStrings.at(j) + "\"; text: \"" + standard.at(i) + "\" }";
+ QDeclarativeComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QDeclarativeTextEdit *textEditObject = qobject_cast<QDeclarativeTextEdit*>(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 Qt 4.6\nTextEdit { horizontalAlignment: \"" + hAlignmentStrings.at(j) + "\"; text: \"" + richText.at(i) + "\" }";
+ QDeclarativeComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QDeclarativeTextEdit *textEditObject = qobject_cast<QDeclarativeTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+ QCOMPARE((int)textEditObject->hAlign(), (int)hAlignments.at(j));
+ }
+ }
+
+}
+
+void tst_qdeclarativetextedit::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 Qt 4.6\nTextEdit { verticalAlignment: \"" + vAlignmentStrings.at(j) + "\"; text: \"" + standard.at(i) + "\" }";
+ QDeclarativeComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QDeclarativeTextEdit *textEditObject = qobject_cast<QDeclarativeTextEdit*>(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 Qt 4.6\nTextEdit { verticalAlignment: \"" + vAlignmentStrings.at(j) + "\"; text: \"" + richText.at(i) + "\" }";
+ QDeclarativeComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QDeclarativeTextEdit *textEditObject = qobject_cast<QDeclarativeTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+ QCOMPARE((int)textEditObject->vAlign(), (int)vAlignments.at(j));
+ }
+ }
+
+}
+
+void tst_qdeclarativetextedit::font()
+{
+ //test size, then bold, then italic, then family
+ {
+ QString componentStr = "import Qt 4.6\nTextEdit { font.pointSize: 40; text: \"Hello World\" }";
+ QDeclarativeComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QDeclarativeTextEdit *textEditObject = qobject_cast<QDeclarativeTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->font().pointSize(), 40);
+ QCOMPARE(textEditObject->font().bold(), false);
+ QCOMPARE(textEditObject->font().italic(), false);
+ }
+
+ {
+ QString componentStr = "import Qt 4.6\nTextEdit { font.bold: true; text: \"Hello World\" }";
+ QDeclarativeComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QDeclarativeTextEdit *textEditObject = qobject_cast<QDeclarativeTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->font().bold(), true);
+ QCOMPARE(textEditObject->font().italic(), false);
+ }
+
+ {
+ QString componentStr = "import Qt 4.6\nTextEdit { font.italic: true; text: \"Hello World\" }";
+ QDeclarativeComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QDeclarativeTextEdit *textEditObject = qobject_cast<QDeclarativeTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->font().italic(), true);
+ QCOMPARE(textEditObject->font().bold(), false);
+ }
+
+ {
+ QString componentStr = "import Qt 4.6\nTextEdit { font.family: \"Helvetica\"; text: \"Hello World\" }";
+ QDeclarativeComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QDeclarativeTextEdit *textEditObject = qobject_cast<QDeclarativeTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->font().family(), QString("Helvetica"));
+ QCOMPARE(textEditObject->font().bold(), false);
+ QCOMPARE(textEditObject->font().italic(), false);
+ }
+
+ {
+ QString componentStr = "import Qt 4.6\nTextEdit { font.family: \"\"; text: \"Hello World\" }";
+ QDeclarativeComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QDeclarativeTextEdit *textEditObject = qobject_cast<QDeclarativeTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->font().family(), QString(""));
+ }
+}
+
+void tst_qdeclarativetextedit::color()
+{
+ //test normal
+ for (int i = 0; i < colorStrings.size(); i++)
+ {
+ QString componentStr = "import Qt 4.6\nTextEdit { color: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
+ QDeclarativeComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QDeclarativeTextEdit *textEditObject = qobject_cast<QDeclarativeTextEdit*>(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 Qt 4.6\nTextEdit { selectionColor: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
+ QDeclarativeComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QDeclarativeTextEdit *textEditObject = qobject_cast<QDeclarativeTextEdit*>(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 Qt 4.6\nTextEdit { selectedTextColor: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
+ QDeclarativeComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QDeclarativeTextEdit *textEditObject = qobject_cast<QDeclarativeTextEdit*>(texteditComponent.create());
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->selectedTextColor(), QColor(colorStrings.at(i)));
+ }
+
+ {
+ QString colorStr = "#AA001234";
+ QColor testColor("#001234");
+ testColor.setAlpha(170);
+
+ QString componentStr = "import Qt 4.6\nTextEdit { color: \"" + colorStr + "\"; text: \"Hello World\" }";
+ QDeclarativeComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QDeclarativeTextEdit *textEditObject = qobject_cast<QDeclarativeTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->color(), testColor);
+ }
+}
+
+void tst_qdeclarativetextedit::textMargin()
+{
+ for(qreal i=0; i<=10; i+=0.3){
+ QString componentStr = "import Qt 4.6\nTextEdit { textMargin: " + QString::number(i) + "; text: \"Hello World\" }";
+ QDeclarativeComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QDeclarativeTextEdit *textEditObject = qobject_cast<QDeclarativeTextEdit*>(texteditComponent.create());
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->textMargin(), i);
+ }
+}
+
+void tst_qdeclarativetextedit::persistentSelection()
+{
+ {
+ QString componentStr = "import Qt 4.6\nTextEdit { persistentSelection: true; text: \"Hello World\" }";
+ QDeclarativeComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QDeclarativeTextEdit *textEditObject = qobject_cast<QDeclarativeTextEdit*>(texteditComponent.create());
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->persistentSelection(), true);
+ }
+
+ {
+ QString componentStr = "import Qt 4.6\nTextEdit { persistentSelection: false; text: \"Hello World\" }";
+ QDeclarativeComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QDeclarativeTextEdit *textEditObject = qobject_cast<QDeclarativeTextEdit*>(texteditComponent.create());
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->persistentSelection(), false);
+ }
+}
+
+void tst_qdeclarativetextedit::focusOnPress()
+{
+ {
+ QString componentStr = "import Qt 4.6\nTextEdit { focusOnPress: true; text: \"Hello World\" }";
+ QDeclarativeComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QDeclarativeTextEdit *textEditObject = qobject_cast<QDeclarativeTextEdit*>(texteditComponent.create());
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->focusOnPress(), true);
+ }
+
+ {
+ QString componentStr = "import Qt 4.6\nTextEdit { focusOnPress: false; text: \"Hello World\" }";
+ QDeclarativeComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QDeclarativeTextEdit *textEditObject = qobject_cast<QDeclarativeTextEdit*>(texteditComponent.create());
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->focusOnPress(), false);
+ }
+}
+
+void tst_qdeclarativetextedit::selection()
+{
+ QString testStr = standard[0];//TODO: What should happen for multiline/rich text?
+ QString componentStr = "import Qt 4.6\nTextEdit { text: \""+ testStr +"\"; }";
+ QDeclarativeComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QDeclarativeTextEdit *textEditObject = qobject_cast<QDeclarativeTextEdit*>(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());
+
+ //Test selection
+ for(int i=0; i<= testStr.size(); i++) {
+ textEditObject->setSelectionEnd(i);
+ QCOMPARE(testStr.mid(0,i), textEditObject->selectedText());
+ }
+ for(int i=0; i<= testStr.size(); i++) {
+ textEditObject->setSelectionStart(i);
+ 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());
+
+ for(int i=0; i< testStr.size(); i++) {
+ textEditObject->setSelectionStart(i);
+ QCOMPARE(textEditObject->selectionEnd(), i);
+ QCOMPARE(testStr.mid(i,0), textEditObject->selectedText());
+ textEditObject->setSelectionEnd(i+1);
+ QCOMPARE(textEditObject->selectionStart(), i);
+ QCOMPARE(testStr.mid(i,1), textEditObject->selectedText());
+ }
+
+ for(int i= testStr.size() - 1; i>0; i--) {
+ textEditObject->setSelectionEnd(i);
+ QCOMPARE(testStr.mid(i,0), textEditObject->selectedText());
+ textEditObject->setSelectionStart(i-1);
+ QCOMPARE(testStr.mid(i-1,1), textEditObject->selectedText());
+ }
+
+ //Test Error Ignoring behaviour
+ textEditObject->setCursorPosition(0);
+ QVERIFY(textEditObject->selectedText().isNull());
+ textEditObject->setSelectionStart(-10);
+ QVERIFY(textEditObject->selectedText().isNull());
+ textEditObject->setSelectionStart(100);
+ QVERIFY(textEditObject->selectedText().isNull());
+ textEditObject->setSelectionEnd(-10);
+ QVERIFY(textEditObject->selectedText().isNull());
+ textEditObject->setSelectionEnd(100);
+ QVERIFY(textEditObject->selectedText().isNull());
+ textEditObject->setSelectionStart(0);
+ textEditObject->setSelectionEnd(10);
+ QVERIFY(textEditObject->selectedText().size() == 10);
+ textEditObject->setSelectionStart(-10);
+ QVERIFY(textEditObject->selectedText().size() == 10);
+ textEditObject->setSelectionStart(100);
+ QVERIFY(textEditObject->selectedText().size() == 10);
+ textEditObject->setSelectionEnd(-10);
+ QVERIFY(textEditObject->selectedText().size() == 10);
+ textEditObject->setSelectionEnd(100);
+ QVERIFY(textEditObject->selectedText().size() == 10);
+}
+
+void tst_qdeclarativetextedit::inputMethodHints()
+{
+ QDeclarativeView *canvas = createView(SRCDIR "/data/inputmethodhints.qml");
+ canvas->show();
+ canvas->setFocus();
+
+ QVERIFY(canvas->rootObject() != 0);
+ QDeclarativeTextEdit *textEditObject = qobject_cast<QDeclarativeTextEdit *>(canvas->rootObject());
+ QVERIFY(textEditObject != 0);
+ QVERIFY(textEditObject->inputMethodHints() & Qt::ImhNoPredictiveText);
+ textEditObject->setInputMethodHints(Qt::ImhUppercaseOnly);
+ QVERIFY(textEditObject->inputMethodHints() & Qt::ImhUppercaseOnly);
+}
+
+void tst_qdeclarativetextedit::cursorDelegate()
+{
+ QDeclarativeView* view = createView(SRCDIR "/data/cursorTest.qml");
+ view->show();
+ view->setFocus();
+ QDeclarativeTextEdit *textEditObject = view->rootObject()->findChild<QDeclarativeTextEdit*>("textEditObject");
+ QVERIFY(textEditObject != 0);
+ QVERIFY(textEditObject->findChild<QDeclarativeItem*>("cursorInstance"));
+ //Test Delegate gets created
+ textEditObject->setFocus(true);
+ QDeclarativeItem* delegateObject = textEditObject->findChild<QDeclarativeItem*>("cursorInstance");
+ QVERIFY(delegateObject);
+ //Test Delegate gets moved
+ for(int i=0; i<= textEditObject->text().length(); i++){
+ textEditObject->setCursorPosition(i);
+ QCOMPARE(textEditObject->cursorRect().x(), qRound(delegateObject->x()));
+ QCOMPARE(textEditObject->cursorRect().y(), qRound(delegateObject->y()));
+ }
+ textEditObject->setCursorPosition(0);
+ QCOMPARE(textEditObject->cursorRect().x(), qRound(delegateObject->x()));
+ QCOMPARE(textEditObject->cursorRect().y(), qRound(delegateObject->y()));
+ //Test Delegate gets deleted
+ textEditObject->setCursorDelegate(0);
+ QVERIFY(!textEditObject->findChild<QDeclarativeItem*>("cursorInstance"));
+}
+
+void tst_qdeclarativetextedit::delegateLoading()
+{
+ TestHTTPServer server(42332);
+ server.serveDirectory(SRCDIR "/data/httpfail", TestHTTPServer::Disconnect);
+ server.serveDirectory(SRCDIR "/data/httpslow", TestHTTPServer::Delay);
+ server.serveDirectory(SRCDIR "/data/http");
+ QDeclarativeView* view = new QDeclarativeView(0);
+ view->setSource(QUrl("http://localhost:42332/cursorHttpTestPass.qml"));
+ view->show();
+ view->setFocus();
+ QTRY_VERIFY(view->rootObject());//Wait for loading to finish.
+ QDeclarativeTextEdit *textEditObject = view->rootObject()->findChild<QDeclarativeTextEdit*>("textEditObject");
+ // view->rootObject()->dumpObjectTree();
+ QVERIFY(textEditObject != 0);
+ textEditObject->setFocus(true);
+ QDeclarativeItem *delegate;
+ delegate = view->rootObject()->findChild<QDeclarativeItem*>("delegateOkay");
+ QVERIFY(delegate);
+ delegate = view->rootObject()->findChild<QDeclarativeItem*>("delegateSlow");
+ QVERIFY(delegate);
+ view->setSource(QUrl("http://localhost:42332/cursorHttpTestFail1.qml"));
+ view->show();
+ view->setFocus();
+ QTRY_VERIFY(!view->rootObject()); // there is fail item inside this test
+ view->setSource(QUrl("http://localhost:42332/cursorHttpTestFail2.qml"));
+ view->show();
+ view->setFocus();
+ QTRY_VERIFY(!view->rootObject()); // there is fail item inside this test
+ //ErrorB should get a component which is ready but component.create() returns null
+ //Not sure how to accomplish this with QDeclarativeTextEdits cursor delegate
+ //###This could be a case of overzealous defensive programming
+ //delegate = view->rootObject()->findChild<QDeclarativeItem*>("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_qdeclarativetextedit::navigation()
+{
+ QDeclarativeView *canvas = createView(SRCDIR "/data/navigation.qml");
+ canvas->show();
+ canvas->setFocus();
+
+ QVERIFY(canvas->rootObject() != 0);
+
+ QDeclarativeItem *input = qobject_cast<QDeclarativeItem *>(qvariant_cast<QObject *>(canvas->rootObject()->property("myInput")));
+
+ QVERIFY(input != 0);
+ QTRY_VERIFY(input->hasFocus() == true);
+ simulateKey(canvas, Qt::Key_Left);
+ QVERIFY(input->hasFocus() == false);
+ simulateKey(canvas, Qt::Key_Right);
+ QVERIFY(input->hasFocus() == true);
+ simulateKey(canvas, Qt::Key_Right);
+ QVERIFY(input->hasFocus() == false);
+ simulateKey(canvas, Qt::Key_Left);
+ QVERIFY(input->hasFocus() == true);
+}
+
+void tst_qdeclarativetextedit::readOnly()
+{
+ QDeclarativeView *canvas = createView(SRCDIR "/data/readOnly.qml");
+ canvas->show();
+ canvas->setFocus();
+
+ QVERIFY(canvas->rootObject() != 0);
+
+ QDeclarativeTextEdit *edit = qobject_cast<QDeclarativeTextEdit *>(qvariant_cast<QObject *>(canvas->rootObject()->property("myInput")));
+
+ QVERIFY(edit != 0);
+ QTRY_VERIFY(edit->hasFocus() == 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);
+}
+
+void tst_qdeclarativetextedit::simulateKey(QDeclarativeView *view, int key)
+{
+ QKeyEvent press(QKeyEvent::KeyPress, key, 0);
+ QKeyEvent release(QKeyEvent::KeyRelease, key, 0);
+
+ QApplication::sendEvent(view, &press);
+ QApplication::sendEvent(view, &release);
+}
+
+QDeclarativeView *tst_qdeclarativetextedit::createView(const QString &filename)
+{
+ QDeclarativeView *canvas = new QDeclarativeView(0);
+
+ canvas->setSource(QUrl::fromLocalFile(filename));
+ return canvas;
+}
+
+class MyInputContext : public QInputContext
+{
+public:
+ MyInputContext() : softwareInputPanelEventReceived(false) {}
+ ~MyInputContext() {}
+
+ QString identifierName() { return QString(); }
+ QString language() { return QString(); }
+
+ void reset() {}
+
+ bool isComposing() const { return false; }
+
+ bool filterEvent( const QEvent *event )
+ {
+ if (event->type() == QEvent::RequestSoftwareInputPanel)
+ softwareInputPanelEventReceived = true;
+ return QInputContext::filterEvent(event);
+ }
+ bool softwareInputPanelEventReceived;
+};
+
+void tst_qdeclarativetextedit::sendRequestSoftwareInputPanelEvent()
+{
+ QGraphicsScene scene;
+ QGraphicsView view(&scene);
+ MyInputContext ic;
+ view.viewport()->setInputContext(&ic);
+ QStyle::RequestSoftwareInputPanel behavior = QStyle::RequestSoftwareInputPanel(
+ view.style()->styleHint(QStyle::SH_RequestSoftwareInputPanel));
+ if ((behavior != QStyle::RSIP_OnMouseClick))
+ QSKIP("This test need to have a style with RSIP_OnMouseClick", SkipSingle);
+ QDeclarativeTextEdit edit;
+ edit.setText("Hello world");
+ edit.setPos(0, 0);
+ scene.addItem(&edit);
+ view.show();
+ qApp->setAutoSipEnabled(true);
+ QApplication::setActiveWindow(&view);
+ QTest::qWaitForWindowShown(&view);
+ QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&view));
+ QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(edit.scenePos()));
+ QApplication::processEvents();
+ QCOMPARE(ic.softwareInputPanelEventReceived, true);
+}
+QTEST_MAIN(tst_qdeclarativetextedit)
+
+#include "tst_qdeclarativetextedit.moc"
diff --git a/tests/auto/declarative/qmlgraphicstextinput/data/cursorTest.qml b/tests/auto/declarative/qdeclarativetextinput/data/cursorTest.qml
index ddc98cc..ddc98cc 100644
--- a/tests/auto/declarative/qmlgraphicstextinput/data/cursorTest.qml
+++ b/tests/auto/declarative/qdeclarativetextinput/data/cursorTest.qml
diff --git a/tests/auto/declarative/qmlgraphicstextinput/data/inputmethodhints.qml b/tests/auto/declarative/qdeclarativetextinput/data/inputmethodhints.qml
index b404682..b404682 100644
--- a/tests/auto/declarative/qmlgraphicstextinput/data/inputmethodhints.qml
+++ b/tests/auto/declarative/qdeclarativetextinput/data/inputmethodhints.qml
diff --git a/tests/auto/declarative/qmlgraphicstextinput/data/masks.qml b/tests/auto/declarative/qdeclarativetextinput/data/masks.qml
index 08a857c..08a857c 100644
--- a/tests/auto/declarative/qmlgraphicstextinput/data/masks.qml
+++ b/tests/auto/declarative/qdeclarativetextinput/data/masks.qml
diff --git a/tests/auto/declarative/qmlgraphicstextinput/data/maxLength.qml b/tests/auto/declarative/qdeclarativetextinput/data/maxLength.qml
index 7cbeadd..7cbeadd 100644
--- a/tests/auto/declarative/qmlgraphicstextinput/data/maxLength.qml
+++ b/tests/auto/declarative/qdeclarativetextinput/data/maxLength.qml
diff --git a/tests/auto/declarative/qmlgraphicstextinput/data/navigation.qml b/tests/auto/declarative/qdeclarativetextinput/data/navigation.qml
index 493db5b..493db5b 100644
--- a/tests/auto/declarative/qmlgraphicstextinput/data/navigation.qml
+++ b/tests/auto/declarative/qdeclarativetextinput/data/navigation.qml
diff --git a/tests/auto/declarative/qmlgraphicstextinput/data/readOnly.qml b/tests/auto/declarative/qdeclarativetextinput/data/readOnly.qml
index c47371a..c47371a 100644
--- a/tests/auto/declarative/qmlgraphicstextinput/data/readOnly.qml
+++ b/tests/auto/declarative/qdeclarativetextinput/data/readOnly.qml
diff --git a/tests/auto/declarative/qmlgraphicstextinput/data/validators.qml b/tests/auto/declarative/qdeclarativetextinput/data/validators.qml
index 0c81548..0c81548 100644
--- a/tests/auto/declarative/qmlgraphicstextinput/data/validators.qml
+++ b/tests/auto/declarative/qdeclarativetextinput/data/validators.qml
diff --git a/tests/auto/declarative/qdeclarativetextinput/qdeclarativetextinput.pro b/tests/auto/declarative/qdeclarativetextinput/qdeclarativetextinput.pro
new file mode 100644
index 0000000..5aed51f
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetextinput/qdeclarativetextinput.pro
@@ -0,0 +1,8 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative gui
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qdeclarativetextinput.cpp
+
+# Define SRCDIR equal to test's source directory
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp
new file mode 100644
index 0000000..8b513e8
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp
@@ -0,0 +1,656 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include "../../../shared/util.h"
+#include <QtDeclarative/qdeclarativeengine.h>
+#include <QFile>
+#include <QtDeclarative/qdeclarativeview.h>
+#include <private/qdeclarativetextinput_p.h>
+#include <QDebug>
+#include <QStyle>
+#include <QInputContext>
+
+class tst_qdeclarativetextinput : public QObject
+
+{
+ Q_OBJECT
+public:
+ tst_qdeclarativetextinput();
+
+private slots:
+ void text();
+ void width();
+ void font();
+ void color();
+ void selection();
+
+ void maxLength();
+ void masks();
+ void validators();
+ void inputMethodHints();
+
+ void cursorDelegate();
+ void navigation();
+ void readOnly();
+
+ void sendRequestSoftwareInputPanelEvent();
+
+private:
+ void simulateKey(QDeclarativeView *, int key);
+ QDeclarativeView *createView(const QString &filename);
+
+ QDeclarativeEngine engine;
+ QStringList standard;
+ QStringList colorStrings;
+};
+
+tst_qdeclarativetextinput::tst_qdeclarativetextinput()
+{
+ standard << "the quick brown fox jumped over the lazy dog"
+ << "It's supercalifragisiticexpialidocious!"
+ << "Hello, world!";
+
+ colorStrings << "aliceblue"
+ << "antiquewhite"
+ << "aqua"
+ << "darkkhaki"
+ << "darkolivegreen"
+ << "dimgray"
+ << "palevioletred"
+ << "lightsteelblue"
+ << "#000000"
+ << "#AAAAAA"
+ << "#FFFFFF"
+ << "#2AC05F";
+}
+
+void tst_qdeclarativetextinput::text()
+{
+ {
+ QDeclarativeComponent textinputComponent(&engine);
+ textinputComponent.setData("import Qt 4.6\nTextInput { text: \"\" }", QUrl());
+ QDeclarativeTextInput *textinputObject = qobject_cast<QDeclarativeTextInput*>(textinputComponent.create());
+
+ QVERIFY(textinputObject != 0);
+ QCOMPARE(textinputObject->text(), QString(""));
+ }
+
+ for (int i = 0; i < standard.size(); i++)
+ {
+ QString componentStr = "import Qt 4.6\nTextInput { text: \"" + standard.at(i) + "\" }";
+ QDeclarativeComponent textinputComponent(&engine);
+ textinputComponent.setData(componentStr.toLatin1(), QUrl());
+ QDeclarativeTextInput *textinputObject = qobject_cast<QDeclarativeTextInput*>(textinputComponent.create());
+
+ QVERIFY(textinputObject != 0);
+ QCOMPARE(textinputObject->text(), standard.at(i));
+ }
+
+}
+
+void tst_qdeclarativetextinput::width()
+{
+ // uses Font metrics to find the width for standard
+ {
+ QDeclarativeComponent textinputComponent(&engine);
+ textinputComponent.setData("import Qt 4.6\nTextInput { text: \"\" }", QUrl());
+ QDeclarativeTextInput *textinputObject = qobject_cast<QDeclarativeTextInput*>(textinputComponent.create());
+
+ QVERIFY(textinputObject != 0);
+ QCOMPARE(textinputObject->width(), 1.);//1 for the cursor
+ }
+
+ for (int i = 0; i < standard.size(); i++)
+ {
+ QFont f;
+ QFontMetricsF fm(f);
+ qreal metricWidth = fm.width(standard.at(i));
+
+ QString componentStr = "import Qt 4.6\nTextInput { text: \"" + standard.at(i) + "\" }";
+ QDeclarativeComponent textinputComponent(&engine);
+ textinputComponent.setData(componentStr.toLatin1(), QUrl());
+ QDeclarativeTextInput *textinputObject = qobject_cast<QDeclarativeTextInput*>(textinputComponent.create());
+
+ QVERIFY(textinputObject != 0);
+ QCOMPARE(textinputObject->width(), qreal(metricWidth) + 1.);//1 for the cursor
+ }
+}
+
+void tst_qdeclarativetextinput::font()
+{
+ //test size, then bold, then italic, then family
+ {
+ QString componentStr = "import Qt 4.6\nTextInput { font.pointSize: 40; text: \"Hello World\" }";
+ QDeclarativeComponent textinputComponent(&engine);
+ textinputComponent.setData(componentStr.toLatin1(), QUrl());
+ QDeclarativeTextInput *textinputObject = qobject_cast<QDeclarativeTextInput*>(textinputComponent.create());
+
+ QVERIFY(textinputObject != 0);
+ QCOMPARE(textinputObject->font().pointSize(), 40);
+ QCOMPARE(textinputObject->font().bold(), false);
+ QCOMPARE(textinputObject->font().italic(), false);
+ }
+
+ {
+ QString componentStr = "import Qt 4.6\nTextInput { font.bold: true; text: \"Hello World\" }";
+ QDeclarativeComponent textinputComponent(&engine);
+ textinputComponent.setData(componentStr.toLatin1(), QUrl());
+ QDeclarativeTextInput *textinputObject = qobject_cast<QDeclarativeTextInput*>(textinputComponent.create());
+
+ QVERIFY(textinputObject != 0);
+ QCOMPARE(textinputObject->font().bold(), true);
+ QCOMPARE(textinputObject->font().italic(), false);
+ }
+
+ {
+ QString componentStr = "import Qt 4.6\nTextInput { font.italic: true; text: \"Hello World\" }";
+ QDeclarativeComponent textinputComponent(&engine);
+ textinputComponent.setData(componentStr.toLatin1(), QUrl());
+ QDeclarativeTextInput *textinputObject = qobject_cast<QDeclarativeTextInput*>(textinputComponent.create());
+
+ QVERIFY(textinputObject != 0);
+ QCOMPARE(textinputObject->font().italic(), true);
+ QCOMPARE(textinputObject->font().bold(), false);
+ }
+
+ {
+ QString componentStr = "import Qt 4.6\nTextInput { font.family: \"Helvetica\"; text: \"Hello World\" }";
+ QDeclarativeComponent textinputComponent(&engine);
+ textinputComponent.setData(componentStr.toLatin1(), QUrl());
+ QDeclarativeTextInput *textinputObject = qobject_cast<QDeclarativeTextInput*>(textinputComponent.create());
+
+ QVERIFY(textinputObject != 0);
+ QCOMPARE(textinputObject->font().family(), QString("Helvetica"));
+ QCOMPARE(textinputObject->font().bold(), false);
+ QCOMPARE(textinputObject->font().italic(), false);
+ }
+
+ {
+ QString componentStr = "import Qt 4.6\nTextInput { font.family: \"\"; text: \"Hello World\" }";
+ QDeclarativeComponent textinputComponent(&engine);
+ textinputComponent.setData(componentStr.toLatin1(), QUrl());
+ QDeclarativeTextInput *textinputObject = qobject_cast<QDeclarativeTextInput*>(textinputComponent.create());
+
+ QVERIFY(textinputObject != 0);
+ QCOMPARE(textinputObject->font().family(), QString(""));
+ }
+}
+
+void tst_qdeclarativetextinput::color()
+{
+ //test color
+ for (int i = 0; i < colorStrings.size(); i++)
+ {
+ QString componentStr = "import Qt 4.6\nTextInput { color: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
+ QDeclarativeComponent textinputComponent(&engine);
+ textinputComponent.setData(componentStr.toLatin1(), QUrl());
+ QDeclarativeTextInput *textinputObject = qobject_cast<QDeclarativeTextInput*>(textinputComponent.create());
+ QVERIFY(textinputObject != 0);
+ QCOMPARE(textinputObject->color(), QColor(colorStrings.at(i)));
+ }
+
+ //test selection color
+ for (int i = 0; i < colorStrings.size(); i++)
+ {
+ QString componentStr = "import Qt 4.6\nTextInput { selectionColor: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
+ QDeclarativeComponent textinputComponent(&engine);
+ textinputComponent.setData(componentStr.toLatin1(), QUrl());
+ QDeclarativeTextInput *textinputObject = qobject_cast<QDeclarativeTextInput*>(textinputComponent.create());
+ QVERIFY(textinputObject != 0);
+ QCOMPARE(textinputObject->selectionColor(), QColor(colorStrings.at(i)));
+ }
+
+ //test selected text color
+ for (int i = 0; i < colorStrings.size(); i++)
+ {
+ QString componentStr = "import Qt 4.6\nTextInput { selectedTextColor: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
+ QDeclarativeComponent textinputComponent(&engine);
+ textinputComponent.setData(componentStr.toLatin1(), QUrl());
+ QDeclarativeTextInput *textinputObject = qobject_cast<QDeclarativeTextInput*>(textinputComponent.create());
+ QVERIFY(textinputObject != 0);
+ QCOMPARE(textinputObject->selectedTextColor(), QColor(colorStrings.at(i)));
+ }
+
+ {
+ QString colorStr = "#AA001234";
+ QColor testColor("#001234");
+ testColor.setAlpha(170);
+
+ QString componentStr = "import Qt 4.6\nTextInput { color: \"" + colorStr + "\"; text: \"Hello World\" }";
+ QDeclarativeComponent textinputComponent(&engine);
+ textinputComponent.setData(componentStr.toLatin1(), QUrl());
+ QDeclarativeTextInput *textinputObject = qobject_cast<QDeclarativeTextInput*>(textinputComponent.create());
+
+ QVERIFY(textinputObject != 0);
+ QCOMPARE(textinputObject->color(), testColor);
+ }
+}
+
+void tst_qdeclarativetextinput::selection()
+{
+ QString testStr = standard[0];
+ QString componentStr = "import Qt 4.6\nTextInput { text: \""+ testStr +"\"; }";
+ QDeclarativeComponent textinputComponent(&engine);
+ textinputComponent.setData(componentStr.toLatin1(), QUrl());
+ QDeclarativeTextInput *textinputObject = qobject_cast<QDeclarativeTextInput*>(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());
+
+ //Test selection
+ for(int i=0; i<= testStr.size(); i++) {
+ textinputObject->setSelectionEnd(i);
+ QCOMPARE(testStr.mid(0,i), textinputObject->selectedText());
+ }
+ for(int i=0; i<= testStr.size(); i++) {
+ textinputObject->setSelectionStart(i);
+ 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());
+
+ for(int i=0; i< testStr.size(); i++) {
+ textinputObject->setSelectionStart(i);
+ QCOMPARE(textinputObject->selectionEnd(), i);
+ QCOMPARE(testStr.mid(i,0), textinputObject->selectedText());
+ textinputObject->setSelectionEnd(i+1);
+ QCOMPARE(textinputObject->selectionStart(), i);
+ QCOMPARE(testStr.mid(i,1), textinputObject->selectedText());
+ }
+
+ for(int i= testStr.size() - 1; i>0; i--) {
+ textinputObject->setSelectionEnd(i);
+ QCOMPARE(testStr.mid(i,0), textinputObject->selectedText());
+ textinputObject->setSelectionStart(i-1);
+ QCOMPARE(testStr.mid(i-1,1), textinputObject->selectedText());
+ }
+
+ //Test Error Ignoring behaviour
+ textinputObject->setCursorPosition(0);
+ QVERIFY(textinputObject->selectedText().isNull());
+ textinputObject->setSelectionStart(-10);
+ QVERIFY(textinputObject->selectedText().isNull());
+ textinputObject->setSelectionStart(100);
+ QVERIFY(textinputObject->selectedText().isNull());
+ textinputObject->setSelectionEnd(-10);
+ QVERIFY(textinputObject->selectedText().isNull());
+ textinputObject->setSelectionEnd(100);
+ QVERIFY(textinputObject->selectedText().isNull());
+ textinputObject->setSelectionStart(0);
+ textinputObject->setSelectionEnd(10);
+ QVERIFY(textinputObject->selectedText().size() == 10);
+ textinputObject->setSelectionStart(-10);
+ QVERIFY(textinputObject->selectedText().size() == 10);
+ textinputObject->setSelectionStart(100);
+ QVERIFY(textinputObject->selectedText().size() == 10);
+ textinputObject->setSelectionEnd(-10);
+ QVERIFY(textinputObject->selectedText().size() == 10);
+ textinputObject->setSelectionEnd(100);
+ QVERIFY(textinputObject->selectedText().size() == 10);
+}
+
+void tst_qdeclarativetextinput::maxLength()
+{
+ //QString componentStr = "import Qt 4.6\nTextInput { maximumLength: 10; }";
+ QDeclarativeView *canvas = createView(SRCDIR "/data/maxLength.qml");
+ canvas->show();
+ canvas->setFocus();
+ QVERIFY(canvas->rootObject() != 0);
+ QDeclarativeTextInput *textinputObject = qobject_cast<QDeclarativeTextInput *>(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->hasFocus() == true);
+ for(int i=0; i<20; i++){
+ QCOMPARE(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);
+ }
+}
+
+void tst_qdeclarativetextinput::masks()
+{
+ //Not a comprehensive test of the possible masks, that's done elsewhere (QLineEdit)
+ //QString componentStr = "import Qt 4.6\nTextInput { inputMask: 'HHHHhhhh'; }";
+ QDeclarativeView *canvas = createView(SRCDIR "/data/masks.qml");
+ canvas->show();
+ canvas->setFocus();
+ QVERIFY(canvas->rootObject() != 0);
+ QDeclarativeTextInput *textinputObject = qobject_cast<QDeclarativeTextInput *>(canvas->rootObject());
+ QVERIFY(textinputObject != 0);
+ QTRY_VERIFY(textinputObject->hasFocus() == true);
+ QVERIFY(textinputObject->text().length() == 0);
+ QCOMPARE(textinputObject->inputMask(), QString("HHHHhhhh; "));
+ for(int i=0; i<10; i++){
+ QCOMPARE(qMin(i,8), textinputObject->text().length());
+ 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);
+ }
+}
+
+void tst_qdeclarativetextinput::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.
+
+ QDeclarativeView *canvas = createView(SRCDIR "/data/validators.qml");
+ canvas->show();
+ canvas->setFocus();
+
+ QVERIFY(canvas->rootObject() != 0);
+
+ QDeclarativeTextInput *intInput = qobject_cast<QDeclarativeTextInput *>(qvariant_cast<QObject *>(canvas->rootObject()->property("intInput")));
+ QVERIFY(intInput);
+ intInput->setFocus(true);
+ QTRY_VERIFY(intInput->hasFocus());
+ QTest::keyPress(canvas, Qt::Key_1);
+ QTest::keyRelease(canvas, Qt::Key_1, Qt::NoModifier ,10);
+ QCOMPARE(intInput->text(), QLatin1String("1"));
+ QCOMPARE(intInput->hasAcceptableInput(), false);
+ QTest::keyPress(canvas, Qt::Key_2);
+ QTest::keyRelease(canvas, Qt::Key_2, Qt::NoModifier ,10);
+ QCOMPARE(intInput->text(), QLatin1String("1"));
+ QCOMPARE(intInput->hasAcceptableInput(), false);
+ QTest::keyPress(canvas, Qt::Key_1);
+ QTest::keyRelease(canvas, Qt::Key_1, Qt::NoModifier ,10);
+ QCOMPARE(intInput->text(), QLatin1String("11"));
+ QCOMPARE(intInput->hasAcceptableInput(), true);
+ QTest::keyPress(canvas, Qt::Key_0);
+ QTest::keyRelease(canvas, Qt::Key_0, Qt::NoModifier ,10);
+ QCOMPARE(intInput->text(), QLatin1String("11"));
+ QCOMPARE(intInput->hasAcceptableInput(), true);
+
+ QDeclarativeTextInput *dblInput = qobject_cast<QDeclarativeTextInput *>(qvariant_cast<QObject *>(canvas->rootObject()->property("dblInput")));
+ QTRY_VERIFY(dblInput);
+ dblInput->setFocus(true);
+ QVERIFY(dblInput->hasFocus() == true);
+ QTest::keyPress(canvas, Qt::Key_1);
+ QTest::keyRelease(canvas, Qt::Key_1, Qt::NoModifier ,10);
+ QCOMPARE(dblInput->text(), QLatin1String("1"));
+ QCOMPARE(dblInput->hasAcceptableInput(), false);
+ QTest::keyPress(canvas, Qt::Key_2);
+ QTest::keyRelease(canvas, Qt::Key_2, Qt::NoModifier ,10);
+ QCOMPARE(dblInput->text(), QLatin1String("12"));
+ QCOMPARE(dblInput->hasAcceptableInput(), true);
+ QTest::keyPress(canvas, Qt::Key_Period);
+ QTest::keyRelease(canvas, Qt::Key_Period, Qt::NoModifier ,10);
+ QCOMPARE(dblInput->text(), QLatin1String("12."));
+ QCOMPARE(dblInput->hasAcceptableInput(), true);
+ QTest::keyPress(canvas, Qt::Key_1);
+ QTest::keyRelease(canvas, Qt::Key_1, Qt::NoModifier ,10);
+ QCOMPARE(dblInput->text(), QLatin1String("12.1"));
+ QCOMPARE(dblInput->hasAcceptableInput(), true);
+ QTest::keyPress(canvas, Qt::Key_1);
+ QTest::keyRelease(canvas, Qt::Key_1, Qt::NoModifier ,10);
+ QCOMPARE(dblInput->text(), QLatin1String("12.11"));
+ QCOMPARE(dblInput->hasAcceptableInput(), true);
+ QTest::keyPress(canvas, Qt::Key_1);
+ QTest::keyRelease(canvas, Qt::Key_1, Qt::NoModifier ,10);
+ QCOMPARE(dblInput->text(), QLatin1String("12.11"));
+ QCOMPARE(dblInput->hasAcceptableInput(), true);
+
+ QDeclarativeTextInput *strInput = qobject_cast<QDeclarativeTextInput *>(qvariant_cast<QObject *>(canvas->rootObject()->property("strInput")));
+ QTRY_VERIFY(strInput);
+ strInput->setFocus(true);
+ QVERIFY(strInput->hasFocus() == true);
+ QTest::keyPress(canvas, Qt::Key_1);
+ QTest::keyRelease(canvas, Qt::Key_1, Qt::NoModifier ,10);
+ QEXPECT_FAIL("","Will not work until QTBUG-8025 is resolved", Abort);
+ QCOMPARE(strInput->text(), QLatin1String(""));
+ QCOMPARE(strInput->hasAcceptableInput(), false);
+ QTest::keyPress(canvas, Qt::Key_A);
+ QTest::keyRelease(canvas, Qt::Key_A, Qt::NoModifier ,10);
+ QCOMPARE(strInput->text(), QLatin1String("a"));
+ QCOMPARE(strInput->hasAcceptableInput(), false);
+ QTest::keyPress(canvas, Qt::Key_A);
+ QTest::keyRelease(canvas, Qt::Key_A, Qt::NoModifier ,10);
+ QCOMPARE(strInput->text(), QLatin1String("aa"));
+ QCOMPARE(strInput->hasAcceptableInput(), true);
+ QTest::keyPress(canvas, Qt::Key_A);
+ QTest::keyRelease(canvas, Qt::Key_A, Qt::NoModifier ,10);
+ QCOMPARE(strInput->text(), QLatin1String("aaa"));
+ QCOMPARE(strInput->hasAcceptableInput(), true);
+ QTest::keyPress(canvas, Qt::Key_A);
+ QTest::keyRelease(canvas, Qt::Key_A, Qt::NoModifier ,10);
+ QCOMPARE(strInput->text(), QLatin1String("aaaa"));
+ QCOMPARE(strInput->hasAcceptableInput(), true);
+ QTest::keyPress(canvas, Qt::Key_A);
+ QTest::keyRelease(canvas, Qt::Key_A, Qt::NoModifier ,10);
+ QCOMPARE(strInput->text(), QLatin1String("aaaa"));
+ QCOMPARE(strInput->hasAcceptableInput(), true);
+}
+
+void tst_qdeclarativetextinput::inputMethodHints()
+{
+ QDeclarativeView *canvas = createView(SRCDIR "/data/inputmethodhints.qml");
+ canvas->show();
+ canvas->setFocus();
+
+ QVERIFY(canvas->rootObject() != 0);
+ QDeclarativeTextInput *textinputObject = qobject_cast<QDeclarativeTextInput *>(canvas->rootObject());
+ QVERIFY(textinputObject != 0);
+ QVERIFY(textinputObject->inputMethodHints() & Qt::ImhNoPredictiveText);
+ textinputObject->setInputMethodHints(Qt::ImhUppercaseOnly);
+ QVERIFY(textinputObject->inputMethodHints() & Qt::ImhUppercaseOnly);
+}
+
+/*
+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_qdeclarativetextinput::navigation()
+{
+ QDeclarativeView *canvas = createView(SRCDIR "/data/navigation.qml");
+ canvas->show();
+ canvas->setFocus();
+
+ QVERIFY(canvas->rootObject() != 0);
+
+ QDeclarativeTextInput *input = qobject_cast<QDeclarativeTextInput *>(qvariant_cast<QObject *>(canvas->rootObject()->property("myInput")));
+
+ QVERIFY(input != 0);
+ input->setCursorPosition(0);
+ QTRY_VERIFY(input->hasFocus() == true);
+ simulateKey(canvas, Qt::Key_Left);
+ QVERIFY(input->hasFocus() == false);
+ simulateKey(canvas, Qt::Key_Right);
+ QVERIFY(input->hasFocus() == true);
+ //QT-2944: If text is selected, then we should deselect first.
+ input->setCursorPosition(input->text().length());
+ input->setSelectionStart(0);
+ input->setSelectionEnd(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->hasFocus() == true);
+ simulateKey(canvas, Qt::Key_Right);
+ QVERIFY(input->hasFocus() == false);
+ simulateKey(canvas, Qt::Key_Left);
+ QVERIFY(input->hasFocus() == true);
+}
+
+void tst_qdeclarativetextinput::cursorDelegate()
+{
+ QDeclarativeView* view = createView(SRCDIR "/data/cursorTest.qml");
+ view->show();
+ view->setFocus();
+ QDeclarativeTextInput *textInputObject = view->rootObject()->findChild<QDeclarativeTextInput*>("textInputObject");
+ QVERIFY(textInputObject != 0);
+ QVERIFY(textInputObject->findChild<QDeclarativeItem*>("cursorInstance"));
+ //Test Delegate gets created
+ textInputObject->setFocus(true);
+ QDeclarativeItem* delegateObject = textInputObject->findChild<QDeclarativeItem*>("cursorInstance");
+ QVERIFY(delegateObject);
+ //Test Delegate gets moved
+ for(int i=0; i<= textInputObject->text().length(); i++){
+ textInputObject->setCursorPosition(i);
+ //+5 is because the TextInput cursorRect is just a 10xHeight area centered on cursor position
+ QCOMPARE(textInputObject->cursorRect().x() + 5, qRound(delegateObject->x()));
+ QCOMPARE(textInputObject->cursorRect().y(), qRound(delegateObject->y()));
+ }
+ textInputObject->setCursorPosition(0);
+ QCOMPARE(textInputObject->cursorRect().x()+5, qRound(delegateObject->x()));
+ QCOMPARE(textInputObject->cursorRect().y(), qRound(delegateObject->y()));
+ //Test Delegate gets deleted
+ textInputObject->setCursorDelegate(0);
+ QVERIFY(!textInputObject->findChild<QDeclarativeItem*>("cursorInstance"));
+}
+
+void tst_qdeclarativetextinput::readOnly()
+{
+ QDeclarativeView *canvas = createView(SRCDIR "/data/readOnly.qml");
+ canvas->show();
+ canvas->setFocus();
+
+ QVERIFY(canvas->rootObject() != 0);
+
+ QDeclarativeTextInput *input = qobject_cast<QDeclarativeTextInput *>(qvariant_cast<QObject *>(canvas->rootObject()->property("myInput")));
+
+ QVERIFY(input != 0);
+ QTRY_VERIFY(input->hasFocus() == 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);
+}
+
+void tst_qdeclarativetextinput::simulateKey(QDeclarativeView *view, int key)
+{
+ QKeyEvent press(QKeyEvent::KeyPress, key, 0);
+ QKeyEvent release(QKeyEvent::KeyRelease, key, 0);
+
+ QApplication::sendEvent(view, &press);
+ QApplication::sendEvent(view, &release);
+}
+
+QDeclarativeView *tst_qdeclarativetextinput::createView(const QString &filename)
+{
+ QDeclarativeView *canvas = new QDeclarativeView(0);
+
+ canvas->setSource(QUrl::fromLocalFile(filename));
+
+ return canvas;
+}
+
+class MyInputContext : public QInputContext
+{
+public:
+ MyInputContext() : softwareInputPanelEventReceived(false) {}
+ ~MyInputContext() {}
+
+ QString identifierName() { return QString(); }
+ QString language() { return QString(); }
+
+ void reset() {}
+
+ bool isComposing() const { return false; }
+
+ bool filterEvent( const QEvent *event )
+ {
+ if (event->type() == QEvent::RequestSoftwareInputPanel)
+ softwareInputPanelEventReceived = true;
+ return QInputContext::filterEvent(event);
+ }
+ bool softwareInputPanelEventReceived;
+};
+
+void tst_qdeclarativetextinput::sendRequestSoftwareInputPanelEvent()
+{
+ QGraphicsScene scene;
+ QGraphicsView view(&scene);
+ MyInputContext ic;
+ view.viewport()->setInputContext(&ic);
+ QStyle::RequestSoftwareInputPanel behavior = QStyle::RequestSoftwareInputPanel(
+ view.style()->styleHint(QStyle::SH_RequestSoftwareInputPanel));
+ if ((behavior != QStyle::RSIP_OnMouseClick))
+ QSKIP("This test need to have a style with RSIP_OnMouseClick", SkipSingle);
+ QDeclarativeTextInput input;
+ input.setText("Hello world");
+ input.setPos(0, 0);
+ scene.addItem(&input);
+ view.show();
+ qApp->setAutoSipEnabled(true);
+ QApplication::setActiveWindow(&view);
+ QTest::qWaitForWindowShown(&view);
+ QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&view));
+ QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(input.scenePos()));
+ QApplication::processEvents();
+ QCOMPARE(ic.softwareInputPanelEventReceived, true);
+}
+
+QTEST_MAIN(tst_qdeclarativetextinput)
+
+#include "tst_qdeclarativetextinput.moc"
diff --git a/tests/auto/declarative/qdeclarativetimer/qdeclarativetimer.pro b/tests/auto/declarative/qdeclarativetimer/qdeclarativetimer.pro
new file mode 100644
index 0000000..b162739
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetimer/qdeclarativetimer.pro
@@ -0,0 +1,7 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative gui
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qdeclarativetimer.cpp
+
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qdeclarativetimer/tst_qdeclarativetimer.cpp b/tests/auto/declarative/qdeclarativetimer/tst_qdeclarativetimer.cpp
new file mode 100644
index 0000000..b120d5d
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetimer/tst_qdeclarativetimer.cpp
@@ -0,0 +1,285 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QtDeclarative/qdeclarativeengine.h>
+#include <QtDeclarative/qdeclarativecomponent.h>
+#include <private/qdeclarativetimer_p.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();
+};
+
+class TimerHelper : public QObject
+{
+ Q_OBJECT
+public:
+ TimerHelper() : QObject(), count(0)
+ {
+ }
+
+ int count;
+
+public slots:
+ void timeout() {
+ ++count;
+ }
+};
+
+#if defined(Q_OS_SYMBIAN) && defined(Q_CC_NOKIAX86)
+// Increase wait as emulator startup can cause unexpected delays
+#define TIMEOUT_TIMEOUT 2000
+#else
+#define TIMEOUT_TIMEOUT 200
+#endif
+
+tst_qdeclarativetimer::tst_qdeclarativetimer()
+{
+}
+
+void tst_qdeclarativetimer::notRepeating()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine);
+ component.setData(QByteArray("import Qt 4.6\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 Qt 4.6\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 Qt 4.6\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);
+
+ delete timer;
+}
+
+void tst_qdeclarativetimer::triggeredOnStart()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine);
+ component.setData(QByteArray("import Qt 4.6\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);
+
+ delete timer;
+}
+
+void tst_qdeclarativetimer::triggeredOnStartRepeat()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine);
+ component.setData(QByteArray("import Qt 4.6\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 Qt 4.6\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 Qt 4.6\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());
+
+ delete timer;
+}
+
+void tst_qdeclarativetimer::restart()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine);
+ component.setData(QByteArray("import Qt 4.6\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;
+}
+
+QTEST_MAIN(tst_qdeclarativetimer)
+
+#include "tst_qdeclarativetimer.moc"
diff --git a/tests/auto/declarative/qmlvaluetypes/data/autoBindingRemoval.2.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/autoBindingRemoval.2.qml
index ce2e82d..ce2e82d 100644
--- a/tests/auto/declarative/qmlvaluetypes/data/autoBindingRemoval.2.qml
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/autoBindingRemoval.2.qml
diff --git a/tests/auto/declarative/qmlvaluetypes/data/autoBindingRemoval.3.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/autoBindingRemoval.3.qml
index c82b533..c82b533 100644
--- a/tests/auto/declarative/qmlvaluetypes/data/autoBindingRemoval.3.qml
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/autoBindingRemoval.3.qml
diff --git a/tests/auto/declarative/qmlvaluetypes/data/autoBindingRemoval.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/autoBindingRemoval.qml
index a8a72f5..a8a72f5 100644
--- a/tests/auto/declarative/qmlvaluetypes/data/autoBindingRemoval.qml
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/autoBindingRemoval.qml
diff --git a/tests/auto/declarative/qmlvaluetypes/data/bindingAssignment.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/bindingAssignment.qml
index a652186..a652186 100644
--- a/tests/auto/declarative/qmlvaluetypes/data/bindingAssignment.qml
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/bindingAssignment.qml
diff --git a/tests/auto/declarative/qmlvaluetypes/data/bindingConflict.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/bindingConflict.qml
index fd25c9f..fd25c9f 100644
--- a/tests/auto/declarative/qmlvaluetypes/data/bindingConflict.qml
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/bindingConflict.qml
diff --git a/tests/auto/declarative/qmlvaluetypes/data/bindingRead.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/bindingRead.qml
index 538d776..538d776 100644
--- a/tests/auto/declarative/qmlvaluetypes/data/bindingRead.qml
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/bindingRead.qml
diff --git a/tests/auto/declarative/qmlvaluetypes/data/bindingVariantCopy.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/bindingVariantCopy.qml
index 691a56c..691a56c 100644
--- a/tests/auto/declarative/qmlvaluetypes/data/bindingVariantCopy.qml
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/bindingVariantCopy.qml
diff --git a/tests/auto/declarative/qmlvaluetypes/data/deletedObject.js b/tests/auto/declarative/qdeclarativevaluetypes/data/deletedObject.js
index af298ff..af298ff 100644
--- a/tests/auto/declarative/qmlvaluetypes/data/deletedObject.js
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/deletedObject.js
diff --git a/tests/auto/declarative/qmlvaluetypes/data/deletedObject.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/deletedObject.qml
index 05459f4..05459f4 100644
--- a/tests/auto/declarative/qmlvaluetypes/data/deletedObject.qml
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/deletedObject.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/enums.1.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/enums.1.qml
new file mode 100644
index 0000000..0eadd50
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/enums.1.qml
@@ -0,0 +1,6 @@
+import Test 1.0
+
+MyTypeObject {
+ font.capitalization: "MixedCase"
+}
+
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/enums.2.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/enums.2.qml
new file mode 100644
index 0000000..81f1c92
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/enums.2.qml
@@ -0,0 +1,6 @@
+import Test 1.0
+
+MyTypeObject {
+ font.capitalization: if (1) "MixedCase"
+}
+
diff --git a/tests/auto/declarative/qmlvaluetypes/data/font_read.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/font_read.qml
index e1d1ce0..e1d1ce0 100644
--- a/tests/auto/declarative/qmlvaluetypes/data/font_read.qml
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/font_read.qml
diff --git a/tests/auto/declarative/qmlvaluetypes/data/font_write.2.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/font_write.2.qml
index b559389..b559389 100644
--- a/tests/auto/declarative/qmlvaluetypes/data/font_write.2.qml
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/font_write.2.qml
diff --git a/tests/auto/declarative/qmlvaluetypes/data/font_write.3.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/font_write.3.qml
index 913ac50..913ac50 100644
--- a/tests/auto/declarative/qmlvaluetypes/data/font_write.3.qml
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/font_write.3.qml
diff --git a/tests/auto/declarative/qmlvaluetypes/data/font_write.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/font_write.qml
index ff4d0a1..ff4d0a1 100644
--- a/tests/auto/declarative/qmlvaluetypes/data/font_write.qml
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/font_write.qml
diff --git a/tests/auto/declarative/qmlvaluetypes/data/point_read.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/point_read.qml
index 3e67de6..3e67de6 100644
--- a/tests/auto/declarative/qmlvaluetypes/data/point_read.qml
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/point_read.qml
diff --git a/tests/auto/declarative/qmlvaluetypes/data/point_write.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/point_write.qml
index 063525a..063525a 100644
--- a/tests/auto/declarative/qmlvaluetypes/data/point_write.qml
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/point_write.qml
diff --git a/tests/auto/declarative/qmlvaluetypes/data/pointf_read.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/pointf_read.qml
index d845a5b..d845a5b 100644
--- a/tests/auto/declarative/qmlvaluetypes/data/pointf_read.qml
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/pointf_read.qml
diff --git a/tests/auto/declarative/qmlvaluetypes/data/pointf_write.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/pointf_write.qml
index 9ee3fc1..9ee3fc1 100644
--- a/tests/auto/declarative/qmlvaluetypes/data/pointf_write.qml
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/pointf_write.qml
diff --git a/tests/auto/declarative/qmlvaluetypes/data/rect_read.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/rect_read.qml
index 5364431..5364431 100644
--- a/tests/auto/declarative/qmlvaluetypes/data/rect_read.qml
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/rect_read.qml
diff --git a/tests/auto/declarative/qmlvaluetypes/data/rect_write.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/rect_write.qml
index 8add453..8add453 100644
--- a/tests/auto/declarative/qmlvaluetypes/data/rect_write.qml
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/rect_write.qml
diff --git a/tests/auto/declarative/qmlvaluetypes/data/rectf_read.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/rectf_read.qml
index aeb9f41..aeb9f41 100644
--- a/tests/auto/declarative/qmlvaluetypes/data/rectf_read.qml
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/rectf_read.qml
diff --git a/tests/auto/declarative/qmlvaluetypes/data/rectf_write.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/rectf_write.qml
index 1e6ff4f..1e6ff4f 100644
--- a/tests/auto/declarative/qmlvaluetypes/data/rectf_write.qml
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/rectf_write.qml
diff --git a/tests/auto/declarative/qmlvaluetypes/data/scriptAccess.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/scriptAccess.qml
index 96592eb..96592eb 100644
--- a/tests/auto/declarative/qmlvaluetypes/data/scriptAccess.qml
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/scriptAccess.qml
diff --git a/tests/auto/declarative/qmlvaluetypes/data/scriptVariantCopy.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/scriptVariantCopy.qml
index 29157e8..29157e8 100644
--- a/tests/auto/declarative/qmlvaluetypes/data/scriptVariantCopy.qml
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/scriptVariantCopy.qml
diff --git a/tests/auto/declarative/qmlvaluetypes/data/size_read.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/size_read.qml
index 86dba03..86dba03 100644
--- a/tests/auto/declarative/qmlvaluetypes/data/size_read.qml
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/size_read.qml
diff --git a/tests/auto/declarative/qmlvaluetypes/data/size_write.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/size_write.qml
index 2f9d10e..2f9d10e 100644
--- a/tests/auto/declarative/qmlvaluetypes/data/size_write.qml
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/size_write.qml
diff --git a/tests/auto/declarative/qmlvaluetypes/data/sizef_read.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/sizef_read.qml
index c6f34e4..c6f34e4 100644
--- a/tests/auto/declarative/qmlvaluetypes/data/sizef_read.qml
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/sizef_read.qml
diff --git a/tests/auto/declarative/qmlvaluetypes/data/sizef_write.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/sizef_write.qml
index f16f0bd..f16f0bd 100644
--- a/tests/auto/declarative/qmlvaluetypes/data/sizef_write.qml
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/sizef_write.qml
diff --git a/tests/auto/declarative/qmlvaluetypes/data/staticAssignment.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/staticAssignment.qml
index b687f89..b687f89 100644
--- a/tests/auto/declarative/qmlvaluetypes/data/staticAssignment.qml
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/staticAssignment.qml
diff --git a/tests/auto/declarative/qmlvaluetypes/data/valueInterceptors.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/valueInterceptors.qml
index 026ae83..026ae83 100644
--- a/tests/auto/declarative/qmlvaluetypes/data/valueInterceptors.qml
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/valueInterceptors.qml
diff --git a/tests/auto/declarative/qmlvaluetypes/data/valueSources.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/valueSources.qml
index d4d4391..d4d4391 100644
--- a/tests/auto/declarative/qmlvaluetypes/data/valueSources.qml
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/valueSources.qml
diff --git a/tests/auto/declarative/qmlvaluetypes/data/vector3d_read.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/vector3d_read.qml
index abdf9f0..abdf9f0 100644
--- a/tests/auto/declarative/qmlvaluetypes/data/vector3d_read.qml
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/vector3d_read.qml
diff --git a/tests/auto/declarative/qmlvaluetypes/data/vector3d_write.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/vector3d_write.qml
index 9c1bf76..9c1bf76 100644
--- a/tests/auto/declarative/qmlvaluetypes/data/vector3d_write.qml
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/vector3d_write.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/qdeclarativevaluetypes.pro b/tests/auto/declarative/qdeclarativevaluetypes/qdeclarativevaluetypes.pro
new file mode 100644
index 0000000..028fc57
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativevaluetypes/qdeclarativevaluetypes.pro
@@ -0,0 +1,10 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative
+macx:CONFIG -= app_bundle
+
+HEADERS += testtypes.h
+
+SOURCES += tst_qdeclarativevaluetypes.cpp \
+ testtypes.cpp
+
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/testtypes.cpp b/tests/auto/declarative/qdeclarativevaluetypes/testtypes.cpp
new file mode 100644
index 0000000..aa8bd6e
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativevaluetypes/testtypes.cpp
@@ -0,0 +1,48 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "testtypes.h"
+
+void registerTypes()
+{
+ QML_REGISTER_TYPE(Test, 1, 0, MyTypeObject, MyTypeObject);
+ QML_REGISTER_TYPE(Test, 1, 0, MyConstantValueSource, MyConstantValueSource);
+ QML_REGISTER_TYPE(Test, 1, 0, MyOffsetValueInterceptor, MyOffsetValueInterceptor);
+}
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/testtypes.h b/tests/auto/declarative/qdeclarativevaluetypes/testtypes.h
new file mode 100644
index 0000000..dfc2829
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativevaluetypes/testtypes.h
@@ -0,0 +1,156 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef TESTTYPES_H
+#define TESTTYPES_H
+
+#include <QObject>
+#include <QPoint>
+#include <QPointF>
+#include <QSize>
+#include <QSizeF>
+#include <QRect>
+#include <QRectF>
+#include <QVector3D>
+#include <QFont>
+#include <qdeclarative.h>
+#include <QDeclarativePropertyValueSource>
+#include <QDeclarativeProperty>
+#include <private/qdeclarativeproperty_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(QSize size READ size WRITE setSize NOTIFY changed);
+ Q_PROPERTY(QSizeF sizef READ sizef WRITE setSizef NOTIFY changed);
+ Q_PROPERTY(QRect rect READ rect WRITE setRect NOTIFY changed);
+ Q_PROPERTY(QRectF rectf READ rectf WRITE setRectf NOTIFY changed);
+ Q_PROPERTY(QVector3D vector READ vector WRITE setVector NOTIFY changed);
+ Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY changed);
+
+public:
+ MyTypeObject() :
+ m_point(10, 4),
+ m_pointf(11.3, -10.9),
+ m_size(1912, 1913),
+ m_sizef(0.1, 100923.2),
+ m_rect(2, 3, 109, 102),
+ m_rectf(103.8, 99.2, 88.1, 77.6),
+ m_vector(23.88, 3.1, 4.3)
+ {
+ 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::AllUppercase);
+ m_font.setLetterSpacing(QFont::AbsoluteSpacing, 10.2);
+ m_font.setWordSpacing(19.7);
+ }
+
+ 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(); }
+
+ 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(); }
+
+ 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(); }
+
+ QVector3D m_vector;
+ QVector3D vector() const { return m_vector; }
+ void setVector(const QVector3D &v) { m_vector = v; emit changed(); }
+
+ QFont m_font;
+ QFont font() const { return m_font; }
+ void setFont(const QFont &v) { m_font = v; emit changed(); }
+
+ void emitRunScript() { emit runScript(); }
+
+signals:
+ void changed();
+ void runScript();
+};
+QML_DECLARE_TYPE(MyTypeObject);
+
+class MyConstantValueSource : public QObject, public QDeclarativePropertyValueSource
+{
+ Q_OBJECT
+public:
+ virtual void setTarget(const QDeclarativeProperty &p) { p.write(3345); }
+};
+QML_DECLARE_TYPE(MyConstantValueSource);
+
+class MyOffsetValueInterceptor : public QObject, public QDeclarativePropertyValueInterceptor
+{
+ Q_OBJECT
+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;
+};
+QML_DECLARE_TYPE(MyOffsetValueInterceptor);
+
+void registerTypes();
+
+#endif // TESTTYPES_H
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp b/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp
new file mode 100644
index 0000000..69646b9
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp
@@ -0,0 +1,616 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+#include <QDeclarativeEngine>
+#include <QDeclarativeComponent>
+#include <QDebug>
+#include <private/qdeclarativevaluetype_p.h>
+#include "testtypes.h"
+
+class tst_qdeclarativevaluetypes : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qdeclarativevaluetypes() {}
+
+private slots:
+ void initTestCase();
+
+ void point();
+ void pointf();
+ void size();
+ void sizef();
+ void rect();
+ void rectf();
+ void vector3d();
+ void font();
+
+ 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();
+
+private:
+ QDeclarativeEngine engine;
+};
+
+void tst_qdeclarativevaluetypes::initTestCase()
+{
+ registerTypes();
+}
+
+inline QUrl TEST_FILE(const QString &filename)
+{
+ return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename);
+}
+
+void tst_qdeclarativevaluetypes::point()
+{
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("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, TEST_FILE("point_write.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->point(), QPoint(11, 12));
+
+ delete object;
+ }
+}
+
+void tst_qdeclarativevaluetypes::pointf()
+{
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("pointf_read.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("p_x").toDouble(), 11.3);
+ QCOMPARE(object->property("p_y").toDouble(), -10.9);
+ QCOMPARE(object->property("copy"), QVariant(QPointF(11.3, -10.9)));
+
+ delete object;
+ }
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("pointf_write.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->pointf(), QPointF(6.8, 9.3));
+
+ delete object;
+ }
+}
+
+void tst_qdeclarativevaluetypes::size()
+{
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("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, TEST_FILE("size_write.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->size(), QSize(13, 88));
+
+ delete object;
+ }
+}
+
+void tst_qdeclarativevaluetypes::sizef()
+{
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("sizef_read.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("s_width").toDouble(), 0.1);
+ QCOMPARE(object->property("s_height").toDouble(), 100923.2);
+ QCOMPARE(object->property("copy"), QVariant(QSizeF(0.1, 100923.2)));
+
+ delete object;
+ }
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("sizef_write.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->sizef(), QSizeF(44.3, 92.8));
+
+ delete object;
+ }
+}
+
+void tst_qdeclarativevaluetypes::rect()
+{
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("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, TEST_FILE("rect_write.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->rect(), QRect(1234, 7, 56, 63));
+
+ delete object;
+ }
+}
+
+void tst_qdeclarativevaluetypes::rectf()
+{
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("rectf_read.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("r_x").toDouble(), 103.8);
+ QCOMPARE(object->property("r_y").toDouble(), 99.2);
+ QCOMPARE(object->property("r_width").toDouble(), 88.1);
+ QCOMPARE(object->property("r_height").toDouble(), 77.6);
+ QCOMPARE(object->property("copy"), QVariant(QRectF(103.8, 99.2, 88.1, 77.6)));
+
+ delete object;
+ }
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("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;
+ }
+}
+
+void tst_qdeclarativevaluetypes::vector3d()
+{
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("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, TEST_FILE("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;
+ }
+}
+
+void tst_qdeclarativevaluetypes::font()
+{
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("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(), object->font().pixelSize());
+ 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, TEST_FILE("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);
+
+ QEXPECT_FAIL("", "QT-2920", Continue);
+ QCOMPARE(object->font(), font);
+
+ delete object;
+ }
+
+ // Test pixelSize
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("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, TEST_FILE("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;
+ }
+}
+
+// Test bindings can write to value types
+void tst_qdeclarativevaluetypes::bindingAssignment()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("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, TEST_FILE("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, TEST_FILE("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, TEST_FILE("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, TEST_FILE("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));
+
+ QEXPECT_FAIL("", "QT-2920", Continue);
+ QCOMPARE(object->rect().x(), 42);
+
+ delete object;
+ }
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("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, TEST_FILE("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)));
+
+ QEXPECT_FAIL("", "QT-2920", Continue);
+ 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, TEST_FILE("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, TEST_FILE("valueInterceptors.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ checkNoErrors(component);
+ QEXPECT_FAIL("", "QT-2920", Abort);
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->rect().x(), 26);
+
+ 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, TEST_FILE("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, TEST_FILE("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, TEST_FILE("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, TEST_FILE("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(QDeclarativeVector3DValueType, QVector3D(18.2, 19.7, 1002));
+ CPP_TEST(QDeclarativeFontValueType, QFont("Helvetica"));
+
+}
+
+void tst_qdeclarativevaluetypes::enums()
+{
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("enums.1.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+ QVERIFY(object->font().capitalization() == QFont::MixedCase);
+ delete object;
+ }
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("enums.2.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+ QVERIFY(object->font().capitalization() == QFont::MixedCase);
+ delete object;
+ }
+}
+
+QTEST_MAIN(tst_qdeclarativevaluetypes)
+
+#include "tst_qdeclarativevaluetypes.moc"
diff --git a/tests/auto/declarative/qmlgraphicswebview/data/basic.html b/tests/auto/declarative/qdeclarativewebview/data/basic.html
index 22e3e24..22e3e24 100644
--- a/tests/auto/declarative/qmlgraphicswebview/data/basic.html
+++ b/tests/auto/declarative/qdeclarativewebview/data/basic.html
diff --git a/tests/auto/declarative/qmlgraphicswebview/data/basic.ico b/tests/auto/declarative/qdeclarativewebview/data/basic.ico
index 8f3d05e..8f3d05e 100644
--- a/tests/auto/declarative/qmlgraphicswebview/data/basic.ico
+++ b/tests/auto/declarative/qdeclarativewebview/data/basic.ico
Binary files differ
diff --git a/tests/auto/declarative/qmlgraphicswebview/data/basic.png b/tests/auto/declarative/qdeclarativewebview/data/basic.png
index 35717cc..35717cc 100644
--- a/tests/auto/declarative/qmlgraphicswebview/data/basic.png
+++ b/tests/auto/declarative/qdeclarativewebview/data/basic.png
Binary files differ
diff --git a/tests/auto/declarative/qmlgraphicswebview/data/basic.qml b/tests/auto/declarative/qdeclarativewebview/data/basic.qml
index 5394837..5394837 100644
--- a/tests/auto/declarative/qmlgraphicswebview/data/basic.qml
+++ b/tests/auto/declarative/qdeclarativewebview/data/basic.qml
diff --git a/tests/auto/declarative/qmlgraphicswebview/data/elements.html b/tests/auto/declarative/qdeclarativewebview/data/elements.html
index 9236867..9236867 100644
--- a/tests/auto/declarative/qmlgraphicswebview/data/elements.html
+++ b/tests/auto/declarative/qdeclarativewebview/data/elements.html
diff --git a/tests/auto/declarative/qmlgraphicswebview/data/elements.qml b/tests/auto/declarative/qdeclarativewebview/data/elements.qml
index 7c030e6..7c030e6 100644
--- a/tests/auto/declarative/qmlgraphicswebview/data/elements.qml
+++ b/tests/auto/declarative/qdeclarativewebview/data/elements.qml
diff --git a/tests/auto/declarative/qdeclarativewebview/data/forward.html b/tests/auto/declarative/qdeclarativewebview/data/forward.html
new file mode 100644
index 0000000..62ab62d
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativewebview/data/forward.html
@@ -0,0 +1,12 @@
+<html>
+<head><title>Forward</title>
+<link rel="icon" sizes="32x32" href="forward.png">
+</head>
+<body leftmargin="0" marginwidth="0">
+<table width="123">
+<tbody>
+<tr><td>This is more.</td></tr>
+</tbody>
+</table>
+</body>
+</html>
diff --git a/tests/auto/declarative/qmlgraphicswebview/data/javaScript.html b/tests/auto/declarative/qdeclarativewebview/data/javaScript.html
index 35270bc..35270bc 100644
--- a/tests/auto/declarative/qmlgraphicswebview/data/javaScript.html
+++ b/tests/auto/declarative/qdeclarativewebview/data/javaScript.html
diff --git a/tests/auto/declarative/qmlgraphicswebview/data/javaScript.qml b/tests/auto/declarative/qdeclarativewebview/data/javaScript.qml
index 07eee88..07eee88 100644
--- a/tests/auto/declarative/qmlgraphicswebview/data/javaScript.qml
+++ b/tests/auto/declarative/qdeclarativewebview/data/javaScript.qml
diff --git a/tests/auto/declarative/qmlgraphicswebview/data/loadError.qml b/tests/auto/declarative/qdeclarativewebview/data/loadError.qml
index 1460f30..1460f30 100644
--- a/tests/auto/declarative/qmlgraphicswebview/data/loadError.qml
+++ b/tests/auto/declarative/qdeclarativewebview/data/loadError.qml
diff --git a/tests/auto/declarative/qmlgraphicswebview/data/newwindows.html b/tests/auto/declarative/qdeclarativewebview/data/newwindows.html
index dd541f9..dd541f9 100644
--- a/tests/auto/declarative/qmlgraphicswebview/data/newwindows.html
+++ b/tests/auto/declarative/qdeclarativewebview/data/newwindows.html
diff --git a/tests/auto/declarative/qmlgraphicswebview/data/newwindows.qml b/tests/auto/declarative/qdeclarativewebview/data/newwindows.qml
index 0bc8263..0bc8263 100644
--- a/tests/auto/declarative/qmlgraphicswebview/data/newwindows.qml
+++ b/tests/auto/declarative/qdeclarativewebview/data/newwindows.qml
diff --git a/tests/auto/declarative/qmlgraphicswebview/data/pixelCache.html b/tests/auto/declarative/qdeclarativewebview/data/pixelCache.html
index 9412674..9412674 100644
--- a/tests/auto/declarative/qmlgraphicswebview/data/pixelCache.html
+++ b/tests/auto/declarative/qdeclarativewebview/data/pixelCache.html
diff --git a/tests/auto/declarative/qmlgraphicswebview/data/pixelCache.qml b/tests/auto/declarative/qdeclarativewebview/data/pixelCache.qml
index 08e4d65..08e4d65 100644
--- a/tests/auto/declarative/qmlgraphicswebview/data/pixelCache.qml
+++ b/tests/auto/declarative/qdeclarativewebview/data/pixelCache.qml
diff --git a/tests/auto/declarative/qdeclarativewebview/data/propertychanges.qml b/tests/auto/declarative/qdeclarativewebview/data/propertychanges.qml
new file mode 100644
index 0000000..3dd4e51
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativewebview/data/propertychanges.qml
@@ -0,0 +1,33 @@
+import Qt 4.6
+
+Item {
+ width: 240
+ height: 160
+ Grid {
+ anchors.fill: parent
+ objectName: "newWindowParent"
+ id: newWindowParent
+ }
+
+ Row {
+ anchors.fill: parent
+ id: oldWindowParent
+ objectName: "oldWindowParent"
+ }
+
+ Loader {
+ sourceComponent: webViewComponent
+ }
+ Component {
+ id: webViewComponent
+ WebView {
+ id: webView
+ objectName: "webView"
+ newWindowComponent: webViewComponent
+ newWindowParent: oldWindowParent
+ url: "basic.html"
+ renderingEnabled: true
+ pressGrabTime: 200
+ }
+ }
+} \ No newline at end of file
diff --git a/tests/auto/declarative/qmlgraphicswebview/data/sethtml.qml b/tests/auto/declarative/qdeclarativewebview/data/sethtml.qml
index 063b5a8..063b5a8 100644
--- a/tests/auto/declarative/qmlgraphicswebview/data/sethtml.qml
+++ b/tests/auto/declarative/qdeclarativewebview/data/sethtml.qml
diff --git a/tests/auto/declarative/qdeclarativewebview/qdeclarativewebview.pro b/tests/auto/declarative/qdeclarativewebview/qdeclarativewebview.pro
new file mode 100644
index 0000000..6af0a60
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativewebview/qdeclarativewebview.pro
@@ -0,0 +1,10 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative
+contains(QT_CONFIG,webkit): QT += webkit
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qdeclarativewebview.cpp testtypes.cpp
+HEADERS += testtypes.h
+
+# Define SRCDIR equal to test's source directory
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qdeclarativewebview/testtypes.cpp b/tests/auto/declarative/qdeclarativewebview/testtypes.cpp
new file mode 100644
index 0000000..7efc214
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativewebview/testtypes.cpp
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "testtypes.h"
+
+void MyWebView::drawContents(QPainter *p, const QRect &r)
+{
+ pp += r.width()*r.height();
+ QDeclarativeWebView::drawContents(p,r);
+}
+
+void registerTypes()
+{
+ QML_REGISTER_TYPE(Test,1,0,MyWebView,MyWebView);
+}
diff --git a/tests/auto/declarative/qdeclarativewebview/testtypes.h b/tests/auto/declarative/qdeclarativewebview/testtypes.h
new file mode 100644
index 0000000..8eb703f
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativewebview/testtypes.h
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef TESTTYPES_H
+#define TESTTYPES_H
+
+#include <private/qdeclarativewebview_p.h>
+
+class MyWebView : public QDeclarativeWebView
+{
+ Q_OBJECT
+ Q_PROPERTY(int pixelsPainted READ pixelsPainted);
+
+public:
+ MyWebView() : pp(0) {}
+
+ int pixelsPainted() const { return pp; }
+
+ void drawContents(QPainter *p, const QRect &r);
+
+private:
+ int pp;
+};
+
+QML_DECLARE_TYPE(MyWebView);
+
+void registerTypes();
+
+#endif // TESTTYPES_H
diff --git a/tests/auto/declarative/qdeclarativewebview/tst_qdeclarativewebview.cpp b/tests/auto/declarative/qdeclarativewebview/tst_qdeclarativewebview.cpp
new file mode 100644
index 0000000..6d16056
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativewebview/tst_qdeclarativewebview.cpp
@@ -0,0 +1,513 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QtTest/QSignalSpy>
+#include "../../../shared/util.h"
+#include <QtDeclarative/qdeclarativeengine.h>
+#include <QtDeclarative/qdeclarativecomponent.h>
+#include <private/qdeclarativewebview_p.h>
+#include <private/qdeclarativewebview_p_p.h>
+#include <private/qdeclarativepositioners_p.h>
+#include <QtWebKit/qwebpage.h>
+#include <QtWebKit/qwebframe.h>
+#include <QtCore/qdir.h>
+#include <QtCore/qfile.h>
+#include <QtGui/qpainter.h>
+#include "testtypes.h"
+
+class tst_qdeclarativewebview : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qdeclarativewebview() {}
+
+private slots:
+ void initTestCase();
+ void basicProperties();
+ void settings();
+ void historyNav();
+ void multipleWindows();
+ void elementAreaAt();
+ void loadError();
+ void setHtml();
+ void javaScript();
+ void cleanupTestCase();
+ void pixelCache();
+ void newWindowParent();
+ void newWindowComponent();
+ void renderingEnabled();
+ void pressGrabTime();
+
+private:
+ void checkNoErrors(const QDeclarativeComponent& component);
+ QDeclarativeEngine engine;
+ QString tmpDir() const
+ {
+ static QString tmpd = QDir::tempPath()+"/tst_qdeclarativewebview-"
+ + QDateTime::currentDateTime().toString(QLatin1String("yyyyMMddhhmmss"));
+ return tmpd;
+ }
+};
+
+void tst_qdeclarativewebview::initTestCase()
+{
+ registerTypes();
+}
+
+static QString strippedHtml(QString html)
+{
+ html.replace(QRegExp("\\s+"),"");
+ return html;
+}
+
+static QString fileContents(const QString& filename)
+{
+ QFile file(filename);
+ file.open(QIODevice::ReadOnly);
+ return QString::fromUtf8(file.readAll());
+}
+
+
+static void removeRecursive(const QString& dirname)
+{
+ QDir dir(dirname);
+ QFileInfoList entries(dir.entryInfoList(QDir::Dirs|QDir::Files|QDir::NoDotAndDotDot));
+ for (int i = 0; i < entries.count(); ++i)
+ if (entries[i].isDir())
+ removeRecursive(entries[i].filePath());
+ else
+ dir.remove(entries[i].fileName());
+ QDir().rmdir(dirname);
+}
+
+void tst_qdeclarativewebview::cleanupTestCase()
+{
+ removeRecursive(tmpDir());
+}
+
+void tst_qdeclarativewebview::checkNoErrors(const QDeclarativeComponent& component)
+{
+ // Wait until the component is ready
+ QTRY_VERIFY(component.isReady());
+
+
+ if (component.isError()) {
+ QList<QDeclarativeError> errors = component.errors();
+ for (int ii = 0; ii < errors.count(); ++ii) {
+ const QDeclarativeError &error = errors.at(ii);
+ QByteArray errorStr = QByteArray::number(error.line()) + ":" +
+ QByteArray::number(error.column()) + ":" +
+ error.description().toUtf8();
+ qWarning() << errorStr;
+ }
+ }
+ QVERIFY(!component.isError());
+}
+
+void tst_qdeclarativewebview::basicProperties()
+{
+ QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/basic.qml"));
+ checkNoErrors(component);
+ QWebSettings::enablePersistentStorage(tmpDir());
+
+ QDeclarativeWebView *wv = qobject_cast<QDeclarativeWebView*>(component.create());
+ QVERIFY(wv != 0);
+ QTRY_COMPARE(wv->progress(), 1.0);
+ QCOMPARE(wv->title(),QString("Basic"));
+ QTRY_COMPARE(wv->icon().width(), 48);
+ QCOMPARE(wv->icon(),QPixmap(SRCDIR "/data/basic.png"));
+ QCOMPARE(wv->statusText(),QString("status here"));
+ QCOMPARE(strippedHtml(fileContents(SRCDIR "/data/basic.html")), strippedHtml(wv->html()));
+ QCOMPARE(wv->width(), 123.0);
+ QCOMPARE(wv->preferredWidth(), 0);
+ QCOMPARE(wv->preferredHeight(), 0);
+ QCOMPARE(wv->zoomFactor(), 1.0);
+ QCOMPARE(wv->url(), QUrl::fromLocalFile(SRCDIR "/data/basic.html"));
+ QCOMPARE(wv->status(), QDeclarativeWebView::Ready);
+ QVERIFY(wv->reloadAction());
+ QVERIFY(wv->reloadAction()->isEnabled());
+ QVERIFY(wv->backAction());
+ QVERIFY(!wv->backAction()->isEnabled());
+ QVERIFY(wv->forwardAction());
+ QVERIFY(!wv->forwardAction()->isEnabled());
+ QVERIFY(wv->stopAction());
+ QVERIFY(!wv->stopAction()->isEnabled());
+
+ wv->setPixelCacheSize(0); // mainly testing that it doesn't crash or anything!
+ QCOMPARE(wv->pixelCacheSize(),0);
+ wv->reloadAction()->trigger();
+ QTRY_COMPARE(wv->progress(), 1.0);
+}
+
+void tst_qdeclarativewebview::settings()
+{
+ QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/basic.qml"));
+ checkNoErrors(component);
+ QDeclarativeWebView *wv = qobject_cast<QDeclarativeWebView*>(component.create());
+ QVERIFY(wv != 0);
+ QTRY_COMPARE(wv->progress(), 1.0);
+
+ QDeclarativeWebSettings *s = wv->settingsObject();
+
+ // merely tests that setting gets stored (in QWebSettings)
+ // behavioural tests are in WebKit.
+ for (int b=0; b<=1; ++b) {
+ bool on = !!b;
+
+ s->setAutoLoadImages(on);
+ s->setDeveloperExtrasEnabled(on);
+ s->setJavaEnabled(on);
+ s->setJavascriptCanAccessClipboard(on);
+ s->setJavascriptCanOpenWindows(on);
+ s->setJavascriptEnabled(on);
+ s->setLinksIncludedInFocusChain(on);
+ s->setLocalContentCanAccessRemoteUrls(on);
+ s->setLocalStorageDatabaseEnabled(on);
+ s->setOfflineStorageDatabaseEnabled(on);
+ s->setOfflineWebApplicationCacheEnabled(on);
+ s->setPluginsEnabled(on);
+ s->setPrintElementBackgrounds(on);
+ s->setPrivateBrowsingEnabled(on);
+ s->setZoomTextOnly(on);
+
+ QVERIFY(s->autoLoadImages() == on);
+ QVERIFY(s->developerExtrasEnabled() == on);
+ QVERIFY(s->javaEnabled() == on);
+ QVERIFY(s->javascriptCanAccessClipboard() == on);
+ QVERIFY(s->javascriptCanOpenWindows() == on);
+ QVERIFY(s->javascriptEnabled() == on);
+ QVERIFY(s->linksIncludedInFocusChain() == on);
+ QVERIFY(s->localContentCanAccessRemoteUrls() == on);
+ QVERIFY(s->localStorageDatabaseEnabled() == on);
+ QVERIFY(s->offlineStorageDatabaseEnabled() == on);
+ QVERIFY(s->offlineWebApplicationCacheEnabled() == on);
+ QVERIFY(s->pluginsEnabled() == on);
+ QVERIFY(s->printElementBackgrounds() == on);
+ QVERIFY(s->privateBrowsingEnabled() == on);
+ QVERIFY(s->zoomTextOnly() == on);
+
+ QVERIFY(s->property("autoLoadImages") == on);
+ QVERIFY(s->property("developerExtrasEnabled") == on);
+ QVERIFY(s->property("javaEnabled") == on);
+ QVERIFY(s->property("javascriptCanAccessClipboard") == on);
+ QVERIFY(s->property("javascriptCanOpenWindows") == on);
+ QVERIFY(s->property("javascriptEnabled") == on);
+ QVERIFY(s->property("linksIncludedInFocusChain") == on);
+ QVERIFY(s->property("localContentCanAccessRemoteUrls") == on);
+ QVERIFY(s->property("localStorageDatabaseEnabled") == on);
+ QVERIFY(s->property("offlineStorageDatabaseEnabled") == on);
+ QVERIFY(s->property("offlineWebApplicationCacheEnabled") == on);
+ QVERIFY(s->property("pluginsEnabled") == on);
+ QVERIFY(s->property("printElementBackgrounds") == on);
+ QVERIFY(s->property("privateBrowsingEnabled") == on);
+ QVERIFY(s->property("zoomTextOnly") == on);
+ }
+}
+
+void tst_qdeclarativewebview::historyNav()
+{
+ QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/basic.qml"));
+ checkNoErrors(component);
+ QWebSettings::enablePersistentStorage(tmpDir());
+
+ QDeclarativeWebView *wv = qobject_cast<QDeclarativeWebView*>(component.create());
+ QVERIFY(wv != 0);
+ for (int i=1; i<=2; ++i) {
+ QTRY_COMPARE(wv->progress(), 1.0);
+ QCOMPARE(wv->title(),QString("Basic"));
+ QTRY_COMPARE(wv->icon().width(), 48);
+ QCOMPARE(wv->icon(),QPixmap(SRCDIR "/data/basic.png"));
+ QCOMPARE(wv->statusText(),QString("status here"));
+ QCOMPARE(strippedHtml(fileContents(SRCDIR "/data/basic.html")), strippedHtml(wv->html()));
+ QCOMPARE(wv->width(), 123.0);
+ QCOMPARE(wv->preferredWidth(), 0);
+ QCOMPARE(wv->zoomFactor(), 1.0);
+ QCOMPARE(wv->url(), QUrl::fromLocalFile(SRCDIR "/data/basic.html"));
+ QCOMPARE(wv->status(), QDeclarativeWebView::Ready);
+ QVERIFY(wv->reloadAction());
+ QVERIFY(wv->reloadAction()->isEnabled());
+ QVERIFY(wv->backAction());
+ QVERIFY(!wv->backAction()->isEnabled());
+ QVERIFY(wv->forwardAction());
+ QVERIFY(!wv->forwardAction()->isEnabled());
+ QVERIFY(wv->stopAction());
+ QVERIFY(!wv->stopAction()->isEnabled());
+
+ wv->reloadAction()->trigger();
+ }
+
+ wv->setUrl(QUrl::fromLocalFile(SRCDIR "/data/forward.html"));
+ QTRY_COMPARE(wv->progress(), 1.0);
+ QCOMPARE(wv->title(),QString("Forward"));
+ QTRY_COMPARE(wv->icon().width(), 32);
+ QCOMPARE(wv->icon(),QPixmap(SRCDIR "/data/forward.png"));
+ QCOMPARE(strippedHtml(fileContents(SRCDIR "/data/forward.html")), strippedHtml(wv->html()));
+ QCOMPARE(wv->url(), QUrl::fromLocalFile(SRCDIR "/data/forward.html"));
+ QCOMPARE(wv->status(), QDeclarativeWebView::Ready);
+ QCOMPARE(wv->statusText(),QString(""));
+ QVERIFY(wv->reloadAction());
+ QVERIFY(wv->reloadAction()->isEnabled());
+ QVERIFY(wv->backAction());
+ QVERIFY(wv->backAction()->isEnabled());
+ QVERIFY(wv->forwardAction());
+ QVERIFY(!wv->forwardAction()->isEnabled());
+ QVERIFY(wv->stopAction());
+ QVERIFY(!wv->stopAction()->isEnabled());
+
+ wv->backAction()->trigger();
+
+ QTRY_COMPARE(wv->progress(), 1.0);
+ QCOMPARE(wv->title(),QString("Basic"));
+ QCOMPARE(strippedHtml(fileContents(SRCDIR "/data/basic.html")), strippedHtml(wv->html()));
+ QCOMPARE(wv->url(), QUrl::fromLocalFile(SRCDIR "/data/basic.html"));
+ QCOMPARE(wv->status(), QDeclarativeWebView::Ready);
+ QVERIFY(wv->reloadAction());
+ QVERIFY(wv->reloadAction()->isEnabled());
+ QVERIFY(wv->backAction());
+ QVERIFY(!wv->backAction()->isEnabled());
+ QVERIFY(wv->forwardAction());
+ QVERIFY(wv->forwardAction()->isEnabled());
+ QVERIFY(wv->stopAction());
+ QVERIFY(!wv->stopAction()->isEnabled());
+}
+
+void tst_qdeclarativewebview::multipleWindows()
+{
+ QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/newwindows.qml"));
+ checkNoErrors(component);
+
+ QDeclarativeGrid *grid = qobject_cast<QDeclarativeGrid*>(component.create());
+ QVERIFY(grid != 0);
+ QTRY_COMPARE(grid->children().count(), 2+5); // Component, Loader, 5 WebViews
+ QDeclarativeItem* popup = qobject_cast<QDeclarativeItem*>(grid->children().at(3)); // first popup after Component, Loaded, original.
+ QVERIFY(popup != 0);
+ QTRY_COMPARE(popup->x(), 150.0);
+}
+
+void tst_qdeclarativewebview::loadError()
+{
+ QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/loadError.qml"));
+ checkNoErrors(component);
+ QWebSettings::enablePersistentStorage(tmpDir());
+
+ QDeclarativeWebView *wv = qobject_cast<QDeclarativeWebView*>(component.create());
+ QVERIFY(wv != 0);
+ for (int i=1; i<=2; ++i) {
+ QTRY_COMPARE(wv->progress(), 1.0);
+ QCOMPARE(wv->title(),QString(""));
+ QCOMPARE(wv->statusText(),QString("")); // HTML 'status bar' text, not error message
+ QCOMPARE(wv->url(), QUrl::fromLocalFile(SRCDIR "/data/does-not-exist.html")); // Unlike QWebPage, which loses url
+ QCOMPARE(wv->status(), QDeclarativeWebView::Error);
+
+ wv->reloadAction()->trigger();
+ }
+}
+
+void tst_qdeclarativewebview::setHtml()
+{
+ QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/sethtml.qml"));
+ checkNoErrors(component);
+ QDeclarativeWebView *wv = qobject_cast<QDeclarativeWebView*>(component.create());
+ QVERIFY(wv != 0);
+ QCOMPARE(wv->html(),QString("<html><head></head><body><p>This is a <b>string</b> set on the WebView</p></body></html>"));
+
+ QSignalSpy spy(wv, SIGNAL(htmlChanged()));
+ wv->setHtml(QString("<html><head><title>Basic</title></head><body><p>text</p></body></html>"));
+ QCOMPARE(spy.count(),1);
+}
+
+void tst_qdeclarativewebview::elementAreaAt()
+{
+ QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/elements.qml"));
+ checkNoErrors(component);
+ QDeclarativeWebView *wv = qobject_cast<QDeclarativeWebView*>(component.create());
+ QVERIFY(wv != 0);
+ QTRY_COMPARE(wv->progress(), 1.0);
+
+ QCOMPARE(wv->elementAreaAt(40,30,100,100),QRect(1,1,75,54)); // Area A in data/elements.html
+ QCOMPARE(wv->elementAreaAt(130,30,200,100),QRect(78,3,110,50)); // Area B
+ QCOMPARE(wv->elementAreaAt(40,30,400,400),QRect(0,0,310,100)); // Whole view
+ QCOMPARE(wv->elementAreaAt(130,30,280,280),QRect(76,1,223,54)); // Area BC
+ QCOMPARE(wv->elementAreaAt(130,30,400,400),QRect(0,0,310,100)); // Whole view
+}
+
+void tst_qdeclarativewebview::javaScript()
+{
+ QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/javaScript.qml"));
+ checkNoErrors(component);
+ QDeclarativeWebView *wv = qobject_cast<QDeclarativeWebView*>(component.create());
+ QVERIFY(wv != 0);
+ QTRY_COMPARE(wv->progress(), 1.0);
+ QCOMPARE(wv->evaluateJavaScript("123").toInt(), 123);
+ QCOMPARE(wv->evaluateJavaScript("window.status").toString(), QString("status here"));
+ QCOMPARE(wv->evaluateJavaScript("window.myjsname.qmlprop").toString(), QString("qmlvalue"));
+}
+
+void tst_qdeclarativewebview::pixelCache()
+{
+ QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/pixelCache.qml"));
+ checkNoErrors(component);
+ MyWebView *wv = qobject_cast<MyWebView*>(component.create());
+ QVERIFY(wv != 0);
+ QTRY_COMPARE(wv->progress(), 1.0);
+ QPixmap pm(150,150);
+ QPainter p(&pm);
+ wv->paint(&p,0,0);
+ const int expected = 120*(150+128); // 120 = width of HTML page, 150=pixmap height, 128=cache extra area
+ QCOMPARE(wv->pixelsPainted(), expected);
+ wv->paint(&p,0,0);
+ QCOMPARE(wv->pixelsPainted(), expected); // nothing new needed to be painted
+ wv->setPixelCacheSize(0); // clears the cache
+ wv->paint(&p,0,0);
+ QCOMPARE(wv->pixelsPainted(), expected*2); // everything needed to be painted
+ // Note that painted things always go into the cache (even if they don't "fit"),
+ // just that they will be removed if anything else needs to be painted.
+ wv->setPixelCacheSize(expected); // won't clear the cache
+ wv->paint(&p,0,0);
+ QCOMPARE(wv->pixelsPainted(), expected*2); // still there
+ wv->setPixelCacheSize(expected-1); // too small - will clear the cache
+ wv->paint(&p,0,0);
+ QCOMPARE(wv->pixelsPainted(), expected*3); // repainted
+}
+
+void tst_qdeclarativewebview::newWindowParent()
+{
+ QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml"));
+ checkNoErrors(component);
+ QDeclarativeItem *rootItem = qobject_cast<QDeclarativeItem*>(component.create());
+ QDeclarativeWebView *wv = rootItem->findChild<QDeclarativeWebView*>("webView");
+ QVERIFY(rootItem != 0);
+ QVERIFY(wv != 0);
+ QTRY_COMPARE(wv->progress(), 1.0);
+
+ QDeclarativeItem* oldWindowParent = rootItem->findChild<QDeclarativeItem*>("oldWindowParent");
+ QCOMPARE(wv->newWindowParent(), oldWindowParent);
+ QSignalSpy newWindowParentSpy(wv, SIGNAL(newWindowParentChanged()));
+
+ QDeclarativeItem* newWindowParent = rootItem->findChild<QDeclarativeItem*>("newWindowParent");
+ wv->setNewWindowParent(newWindowParent);
+ QVERIFY(oldWindowParent);
+ QVERIFY(oldWindowParent->childItems().count() == 0);
+ QCOMPARE(wv->newWindowParent(), newWindowParent);
+ QCOMPARE(newWindowParentSpy.count(),1);
+
+ wv->setNewWindowParent(newWindowParent);
+ QCOMPARE(newWindowParentSpy.count(),1);
+
+ wv->setNewWindowParent(0);
+ QCOMPARE(newWindowParentSpy.count(),2);
+}
+
+void tst_qdeclarativewebview::newWindowComponent()
+{
+ QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml"));
+ checkNoErrors(component);
+ QDeclarativeItem *rootItem = qobject_cast<QDeclarativeItem*>(component.create());
+ QDeclarativeWebView *wv = rootItem->findChild<QDeclarativeWebView*>("webView");
+ QVERIFY(rootItem != 0);
+ QVERIFY(wv != 0);
+ QTRY_COMPARE(wv->progress(), 1.0);
+
+ QDeclarativeComponent substituteComponent(&engine);
+ substituteComponent.setData("import Qt 4.6; WebView { objectName: 'newWebView'; url: 'basic.html'; }", QUrl::fromLocalFile(""));
+ QSignalSpy newWindowComponentSpy(wv, SIGNAL(newWindowComponentChanged()));
+
+ wv->setNewWindowComponent(&substituteComponent);
+ QCOMPARE(wv->newWindowComponent(), &substituteComponent);
+ QCOMPARE(newWindowComponentSpy.count(),1);
+
+ wv->setNewWindowComponent(&substituteComponent);
+ QCOMPARE(newWindowComponentSpy.count(),1);
+
+ wv->setNewWindowComponent(0);
+ QCOMPARE(newWindowComponentSpy.count(),2);
+}
+
+void tst_qdeclarativewebview::renderingEnabled()
+{
+ QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml"));
+ checkNoErrors(component);
+ QDeclarativeItem *rootItem = qobject_cast<QDeclarativeItem*>(component.create());
+ QDeclarativeWebView *wv = rootItem->findChild<QDeclarativeWebView*>("webView");
+ QVERIFY(rootItem != 0);
+ QVERIFY(wv != 0);
+ QTRY_COMPARE(wv->progress(), 1.0);
+
+ QVERIFY(wv->renderingEnabled());
+ QSignalSpy renderingEnabledSpy(wv, SIGNAL(renderingEnabledChanged()));
+
+ wv->setRenderingEnabled(false);
+ QVERIFY(!wv->renderingEnabled());
+ QCOMPARE(renderingEnabledSpy.count(),1);
+
+ wv->setRenderingEnabled(false);
+ QCOMPARE(renderingEnabledSpy.count(),1);
+
+ wv->setRenderingEnabled(true);
+ QCOMPARE(renderingEnabledSpy.count(),2);
+}
+
+void tst_qdeclarativewebview::pressGrabTime()
+{
+ QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml"));
+ checkNoErrors(component);
+ QDeclarativeItem *rootItem = qobject_cast<QDeclarativeItem*>(component.create());
+ QDeclarativeWebView *wv = rootItem->findChild<QDeclarativeWebView*>("webView");
+ QVERIFY(rootItem != 0);
+ QVERIFY(wv != 0);
+ QTRY_COMPARE(wv->progress(), 1.0);
+ QCOMPARE(wv->pressGrabTime(), 200);
+ QSignalSpy pressGrabTimeSpy(wv, SIGNAL(pressGrabTimeChanged()));
+
+ wv->setPressGrabTime(100);
+ QCOMPARE(wv->pressGrabTime(), 100);
+ QCOMPARE(pressGrabTimeSpy.count(),1);
+
+ wv->setPressGrabTime(100);
+ QCOMPARE(pressGrabTimeSpy.count(),1);
+
+ wv->setPressGrabTime(0);
+ QCOMPARE(pressGrabTimeSpy.count(),2);
+}
+
+QTEST_MAIN(tst_qdeclarativewebview)
+
+#include "tst_qdeclarativewebview.moc"
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/abort.expect b/tests/auto/declarative/qdeclarativexmlhttprequest/data/abort.expect
index f43e043..f43e043 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/abort.expect
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/abort.expect
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/abort.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/abort.qml
index d7b9266..d7b9266 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/abort.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/abort.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/abort.reply b/tests/auto/declarative/qdeclarativexmlhttprequest/data/abort.reply
index 7ae6951..7ae6951 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/abort.reply
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/abort.reply
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/abort_opened.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/abort_opened.qml
index 72a45e7..72a45e7 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/abort_opened.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/abort_opened.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/abort_unsent.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/abort_unsent.qml
index aa78cde..aa78cde 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/abort_unsent.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/abort_unsent.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/attr.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/attr.qml
index 9049fc7..9049fc7 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/attr.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/attr.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/attr.xml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/attr.xml
index 2aa64a3..2aa64a3 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/attr.xml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/attr.xml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/callbackException.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/callbackException.qml
index 9255922..9255922 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/callbackException.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/callbackException.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/cdata.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/cdata.qml
index b2d0209..b2d0209 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/cdata.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/cdata.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/cdata.xml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/cdata.xml
index 061d37c..061d37c 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/cdata.xml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/cdata.xml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/constructor.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/constructor.qml
index 93e44fd..93e44fd 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/constructor.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/constructor.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/defaultState.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/defaultState.qml
index 4dcf6f9..4dcf6f9 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/defaultState.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/defaultState.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/document.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/document.qml
index e372361..e372361 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/document.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/document.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/document.xml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/document.xml
index fb693ea..fb693ea 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/document.xml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/document.xml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/domExceptionCodes.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/domExceptionCodes.qml
index de5ee4f..de5ee4f 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/domExceptionCodes.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/domExceptionCodes.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/element.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/element.qml
index 78c0374..78c0374 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/element.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/element.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/element.xml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/element.xml
index 071ffae..071ffae 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/element.xml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/element.xml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/getAllResponseHeaders.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders.qml
index 8d67fad..8d67fad 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/getAllResponseHeaders.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/getAllResponseHeaders_args.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders_args.qml
index 37124c7..37124c7 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/getAllResponseHeaders_args.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders_args.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/getAllResponseHeaders_sent.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders_sent.qml
index 505e4b1..505e4b1 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/getAllResponseHeaders_sent.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders_sent.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/getAllResponseHeaders_unsent.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders_unsent.qml
index 20fb040..20fb040 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/getAllResponseHeaders_unsent.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders_unsent.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader.expect b/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader.expect
index a740c79..a740c79 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader.expect
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader.expect
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader.qml
index 2f949e1..2f949e1 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader.reply b/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader.reply
index c4b4bb2..c4b4bb2 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader.reply
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader.reply
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader_args.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader_args.qml
index d5aa4b1..d5aa4b1 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader_args.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader_args.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader_sent.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader_sent.qml
index 7538ffd..7538ffd 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader_sent.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader_sent.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader_unsent.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader_unsent.qml
index 3b55802..3b55802 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader_unsent.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader_unsent.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/instanceStateValues.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/instanceStateValues.qml
index b8d01c4..b8d01c4 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/instanceStateValues.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/instanceStateValues.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/invalidMethodUsage.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/invalidMethodUsage.qml
index b30989b..b30989b 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/invalidMethodUsage.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/invalidMethodUsage.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/open.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/open.qml
index c06bae3..c06bae3 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/open.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/open.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/open_arg_count.1.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_arg_count.1.qml
index b6d4c32..b6d4c32 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/open_arg_count.1.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_arg_count.1.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/open_arg_count.2.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_arg_count.2.qml
index 8c86c20..8c86c20 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/open_arg_count.2.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_arg_count.2.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/open_invalid_method.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_invalid_method.qml
index 69f79ae..69f79ae 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/open_invalid_method.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_invalid_method.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/open_network.expect b/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_network.expect
index a740c79..a740c79 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/open_network.expect
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_network.expect
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/open_network.reply b/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_network.reply
index 7ae6951..7ae6951 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/open_network.reply
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_network.reply
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/open_network.wait b/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_network.wait
index e69de29..e69de29 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/open_network.wait
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_network.wait
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/open_sync.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_sync.qml
index 1477279..1477279 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/open_sync.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_sync.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/open_user.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_user.qml
index 19e37fa..19e37fa 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/open_user.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_user.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/open_username.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_username.qml
index 983ea14..983ea14 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/open_username.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_username.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/redirectError.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/redirectError.qml
index 6b345cc..6b345cc 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/redirectError.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/redirectError.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/redirectRecur.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/redirectRecur.qml
index c0321dc..c0321dc 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/redirectRecur.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/redirectRecur.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/redirects.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/redirects.qml
index f6fabdb..f6fabdb 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/redirects.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/redirects.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/redirecttarget.html b/tests/auto/declarative/qdeclarativexmlhttprequest/data/redirecttarget.html
index 95f35e0..95f35e0 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/redirecttarget.html
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/redirecttarget.html
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/responseText.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/responseText.qml
index 4bb3a7a..4bb3a7a 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/responseText.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/responseText.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/responseXML_invalid.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/responseXML_invalid.qml
index 63f288e..63f288e 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/responseXML_invalid.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/responseXML_invalid.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/seconddocument.html b/tests/auto/declarative/qdeclarativexmlhttprequest/data/seconddocument.html
index a33f44b..a33f44b 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/seconddocument.html
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/seconddocument.html
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/send_alreadySent.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_alreadySent.qml
index 0bad7df..0bad7df 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/send_alreadySent.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_alreadySent.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/send_data.1.expect b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.1.expect
index 81dd4a0..81dd4a0 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/send_data.1.expect
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.1.expect
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/send_data.1.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.1.qml
index 03543a9..03543a9 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/send_data.1.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.1.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/send_data.2.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.2.qml
index 79a27b6..79a27b6 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/send_data.2.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.2.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/send_data.3.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.3.qml
index e048769..e048769 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/send_data.3.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.3.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/send_data.4.expect b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.4.expect
index 8fcf3ac..8fcf3ac 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/send_data.4.expect
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.4.expect
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/send_data.4.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.4.qml
index 7ab0b27..7ab0b27 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/send_data.4.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.4.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/send_data.5.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.5.qml
index 29bf2c2..29bf2c2 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/send_data.5.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.5.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/send_data.6.expect b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.6.expect
index 97e6fac..97e6fac 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/send_data.6.expect
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.6.expect
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/send_data.6.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.6.qml
index 135f45c..135f45c 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/send_data.6.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.6.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/send_data.7.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.7.qml
index 4a09527..4a09527 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/send_data.7.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.7.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/send_data.reply b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.reply
index 7ae6951..7ae6951 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/send_data.reply
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.reply
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/send_ignoreData.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData.qml
index dd5fa46..dd5fa46 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/send_ignoreData.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/send_ignoreData.reply b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData.reply
index 7ae6951..7ae6951 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/send_ignoreData.reply
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData.reply
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/send_ignoreData_GET.expect b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData_GET.expect
index a740c79..a740c79 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/send_ignoreData_GET.expect
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData_GET.expect
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/send_ignoreData_PUT.expect b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData_PUT.expect
index 991bd59..991bd59 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/send_ignoreData_PUT.expect
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData_PUT.expect
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/send_unsent.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_unsent.qml
index 7f51ecf..7f51ecf 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/send_unsent.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_unsent.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader.expect b/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader.expect
index 4600f2a..4600f2a 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader.expect
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader.expect
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader.qml
index b0723aa..b0723aa 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader.reply b/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader.reply
index 7ae6951..7ae6951 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader.reply
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader.reply
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader_args.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_args.qml
index 8305ae1..8305ae1 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader_args.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_args.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader_illegalName.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_illegalName.qml
index bf31eca..bf31eca 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader_illegalName.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_illegalName.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader_sent.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_sent.qml
index c2bbc6e..c2bbc6e 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader_sent.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_sent.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader_unsent.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_unsent.qml
index 30bc93e..30bc93e 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader_unsent.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_unsent.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/staticStateValues.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/staticStateValues.qml
index ec1c5d8..ec1c5d8 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/staticStateValues.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/staticStateValues.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/status.200.reply b/tests/auto/declarative/qdeclarativexmlhttprequest/data/status.200.reply
index 7ae6951..7ae6951 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/status.200.reply
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/status.200.reply
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/status.404.reply b/tests/auto/declarative/qdeclarativexmlhttprequest/data/status.404.reply
index 2e29f56..2e29f56 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/status.404.reply
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/status.404.reply
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/status.expect b/tests/auto/declarative/qdeclarativexmlhttprequest/data/status.expect
index a740c79..a740c79 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/status.expect
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/status.expect
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/status.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/status.qml
index 04202c4..04202c4 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/status.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/status.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/statusText.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/statusText.qml
index 8becc3b..8becc3b 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/statusText.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/statusText.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/testdocument.html b/tests/auto/declarative/qdeclarativexmlhttprequest/data/testdocument.html
index 8fe0f4b..8fe0f4b 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/testdocument.html
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/testdocument.html
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/text.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/text.qml
index 4615a07..4615a07 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/text.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/text.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/text.xml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/text.xml
index e741688..e741688 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/text.xml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/text.xml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/qdeclarativexmlhttprequest.pro b/tests/auto/declarative/qdeclarativexmlhttprequest/qdeclarativexmlhttprequest.pro
new file mode 100644
index 0000000..7bc92af
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/qdeclarativexmlhttprequest.pro
@@ -0,0 +1,13 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative network
+macx:CONFIG -= app_bundle
+
+INCLUDEPATH += ../shared/
+HEADERS += ../shared/testhttpserver.h
+
+SOURCES += tst_qdeclarativexmlhttprequest.cpp \
+ ../shared/testhttpserver.cpp
+
+
+# Define SRCDIR equal to test's source directory
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/tst_qdeclarativexmlhttprequest.cpp b/tests/auto/declarative/qdeclarativexmlhttprequest/tst_qdeclarativexmlhttprequest.cpp
new file mode 100644
index 0000000..37d48fa
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/tst_qdeclarativexmlhttprequest.cpp
@@ -0,0 +1,1315 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+#include <QDeclarativeEngine>
+#include <QDeclarativeComponent>
+#include <QDebug>
+#include <QNetworkCookieJar>
+#include "testhttpserver.h"
+
+#define SERVER_PORT 14445
+
+class tst_qdeclarativexmlhttprequest : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qdeclarativexmlhttprequest() {}
+
+private slots:
+ void initTestCase() {
+ if (QLocale::system().name().replace(QChar::fromAscii('_'),QChar::fromAscii('-')) != QLatin1String("en-US")) {
+ qWarning() << "Test will fail unless LANG is en_US";
+ }
+ }
+
+ void domExceptionCodes();
+ void callbackException();
+ void callbackException_data();
+ void staticStateValues();
+ void instanceStateValues();
+ void constructor();
+ void defaultState();
+ void open();
+ void open_invalid_method();
+ void open_sync();
+ void open_arg_count();
+ void setRequestHeader();
+ 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 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 statusText();
+ void responseText();
+ void responseXML_invalid();
+ void invalidMethodUsage();
+ void redirects();
+
+ // 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;
+};
+
+inline QUrl TEST_FILE(const QString &filename)
+{
+ return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename);
+}
+
+// Test that the dom exception codes are correct
+void tst_qdeclarativexmlhttprequest::domExceptionCodes()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("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;
+}
+
+#define TRY_WAIT(expr) \
+ do { \
+ for (int ii = 0; ii < 6; ++ii) { \
+ if ((expr)) break; \
+ QTest::qWait(50); \
+ } \
+ QVERIFY((expr)); \
+ } while (false)
+
+
+void tst_qdeclarativexmlhttprequest::callbackException_data()
+{
+ QTest::addColumn<QString>("which");
+ 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 = TEST_FILE("callbackException.qml").toString() + ":"+QString::number(line)+": Error: Exception from Callback";
+ QTest::ignoreMessage(QtWarningMsg, expect.toLatin1());
+
+ QDeclarativeComponent component(&engine, TEST_FILE("callbackException.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("url", "testdocument.html");
+ object->setProperty("which", which);
+ component.completeCreate();
+
+ TRY_WAIT(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, TEST_FILE("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, TEST_FILE("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, TEST_FILE("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, TEST_FILE("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()
+{
+ // Relative url
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("open.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);
+
+ TRY_WAIT(object->property("dataOK").toBool() == true);
+
+ delete object;
+ }
+
+ // Absolute url
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("open.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("url", TEST_FILE("testdocument.html").toString());
+ 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);
+
+ TRY_WAIT(object->property("dataOK").toBool() == true);
+
+ delete object;
+ }
+
+ // Absolute network url
+ {
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ QVERIFY(server.wait(TEST_FILE("open_network.expect"),
+ TEST_FILE("open_network.reply"),
+ TEST_FILE("testdocument.html")));
+
+ QDeclarativeComponent component(&engine, TEST_FILE("open.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("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);
+
+ TRY_WAIT(object->property("dataOK").toBool() == true);
+
+ delete object;
+ }
+
+ // User/pass
+ {
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ QVERIFY(server.wait(TEST_FILE("open_network.expect"),
+ TEST_FILE("open_network.reply"),
+ TEST_FILE("testdocument.html")));
+
+ QDeclarativeComponent component(&engine, TEST_FILE("open_user.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("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);
+
+ TRY_WAIT(object->property("dataOK").toBool() == true);
+
+ // ### Check that the username/password were sent to the server
+
+ delete object;
+ }
+}
+
+// Test that calling XMLHttpRequest.open() with an invalid method raises an exception
+void tst_qdeclarativexmlhttprequest::open_invalid_method()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("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, TEST_FILE("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, TEST_FILE("open_arg_count.1.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("exceptionThrown").toBool(), true);
+
+ delete object;
+ }
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("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(TEST_FILE("setRequestHeader.expect"),
+ TEST_FILE("setRequestHeader.reply"),
+ TEST_FILE("testdocument.html")));
+
+ QDeclarativeComponent component(&engine, TEST_FILE("setRequestHeader.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
+ component.completeCreate();
+
+ TRY_WAIT(object->property("dataOK").toBool() == true);
+
+ delete object;
+}
+
+// Test setting headers before open() throws exception
+void tst_qdeclarativexmlhttprequest::setRequestHeader_unsent()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("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(TEST_FILE("open_network.expect"),
+ TEST_FILE("open_network.reply"),
+ TEST_FILE("testdocument.html")));
+
+ QDeclarativeComponent component(&engine, TEST_FILE("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);
+
+ TRY_WAIT(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(TEST_FILE("open_network.expect"),
+ TEST_FILE("open_network.reply"),
+ TEST_FILE("testdocument.html")));
+
+ QDeclarativeComponent component(&engine, TEST_FILE("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);
+
+ TRY_WAIT(object->property("dataOK").toBool() == true);
+
+ delete object;
+}
+
+// Invalid arg count throws exception
+void tst_qdeclarativexmlhttprequest::setRequestHeader_args()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("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, TEST_FILE("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, TEST_FILE("send_alreadySent.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toBool(), true);
+ TRY_WAIT(object->property("dataOK").toBool() == true);
+
+ delete object;
+}
+
+// Test that send for a GET or HEAD ignores data
+void tst_qdeclarativexmlhttprequest::send_ignoreData()
+{
+ {
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ QVERIFY(server.wait(TEST_FILE("send_ignoreData_GET.expect"),
+ TEST_FILE("send_ignoreData.reply"),
+ TEST_FILE("testdocument.html")));
+
+ QDeclarativeComponent component(&engine, TEST_FILE("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();
+
+ TRY_WAIT(object->property("dataOK").toBool() == true);
+
+ delete object;
+ }
+
+ {
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ QVERIFY(server.wait(TEST_FILE("send_ignoreData_PUT.expect"),
+ TEST_FILE("send_ignoreData.reply"),
+ TEST_FILE("testdocument.html")));
+
+ QDeclarativeComponent component(&engine, TEST_FILE("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();
+
+ TRY_WAIT(object->property("dataOK").toBool() == true);
+
+ delete object;
+ }
+}
+
+// Test that send()'ing data works
+void tst_qdeclarativexmlhttprequest::send_withdata()
+{
+ // No content-type
+ {
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ QVERIFY(server.wait(TEST_FILE("send_data.1.expect"),
+ TEST_FILE("send_data.reply"),
+ TEST_FILE("testdocument.html")));
+
+ QDeclarativeComponent component(&engine, TEST_FILE("send_data.1.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
+ component.completeCreate();
+
+ TRY_WAIT(object->property("dataOK").toBool() == true);
+
+ delete object;
+ }
+
+ // Correct content-type
+ {
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ QVERIFY(server.wait(TEST_FILE("send_data.1.expect"),
+ TEST_FILE("send_data.reply"),
+ TEST_FILE("testdocument.html")));
+
+ QDeclarativeComponent component(&engine, TEST_FILE("send_data.2.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
+ component.completeCreate();
+
+ TRY_WAIT(object->property("dataOK").toBool() == true);
+
+ delete object;
+ }
+
+ // Incorrect content-type
+ {
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ QVERIFY(server.wait(TEST_FILE("send_data.1.expect"),
+ TEST_FILE("send_data.reply"),
+ TEST_FILE("testdocument.html")));
+
+ QDeclarativeComponent component(&engine, TEST_FILE("send_data.3.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
+ component.completeCreate();
+
+ TRY_WAIT(object->property("dataOK").toBool() == true);
+
+ delete object;
+ }
+
+ // Correct content-type - out of order
+ {
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ QVERIFY(server.wait(TEST_FILE("send_data.4.expect"),
+ TEST_FILE("send_data.reply"),
+ TEST_FILE("testdocument.html")));
+
+ QDeclarativeComponent component(&engine, TEST_FILE("send_data.4.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
+ component.completeCreate();
+
+ TRY_WAIT(object->property("dataOK").toBool() == true);
+
+ delete object;
+ }
+
+ // Incorrect content-type - out of order
+ {
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ QVERIFY(server.wait(TEST_FILE("send_data.4.expect"),
+ TEST_FILE("send_data.reply"),
+ TEST_FILE("testdocument.html")));
+
+ QDeclarativeComponent component(&engine, TEST_FILE("send_data.5.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
+ component.completeCreate();
+
+ TRY_WAIT(object->property("dataOK").toBool() == true);
+
+ delete object;
+ }
+
+ // PUT
+ {
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ QVERIFY(server.wait(TEST_FILE("send_data.6.expect"),
+ TEST_FILE("send_data.reply"),
+ TEST_FILE("testdocument.html")));
+
+ QDeclarativeComponent component(&engine, TEST_FILE("send_data.6.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
+ component.completeCreate();
+
+ TRY_WAIT(object->property("dataOK").toBool() == true);
+
+ delete object;
+ }
+
+ // Correct content-type - no charset
+ {
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ QVERIFY(server.wait(TEST_FILE("send_data.1.expect"),
+ TEST_FILE("send_data.reply"),
+ TEST_FILE("testdocument.html")));
+
+ QDeclarativeComponent component(&engine, TEST_FILE("send_data.7.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
+ component.completeCreate();
+
+ TRY_WAIT(object->property("dataOK").toBool() == true);
+
+ delete object;
+ }
+}
+
+// Test abort() has no effect in unsent state
+void tst_qdeclarativexmlhttprequest::abort_unsent()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("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);
+
+ TRY_WAIT(object->property("dataOK").toBool() == true);
+
+ delete object;
+}
+
+// Test abort() cancels an open (but unsent) request
+void tst_qdeclarativexmlhttprequest::abort_opened()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("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);
+
+ TRY_WAIT(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(TEST_FILE("abort.expect"),
+ TEST_FILE("abort.reply"),
+ TEST_FILE("testdocument.html")));
+
+ QDeclarativeComponent component(&engine, TEST_FILE("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);
+
+ TRY_WAIT(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(TEST_FILE("getResponseHeader.expect"),
+ TEST_FILE("getResponseHeader.reply"),
+ TEST_FILE("testdocument.html")));
+
+
+ QDeclarativeComponent component(&engine, TEST_FILE("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);
+
+ TRY_WAIT(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, TEST_FILE("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, TEST_FILE("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, TEST_FILE("getResponseHeader_args.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ TRY_WAIT(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(TEST_FILE("getResponseHeader.expect"),
+ TEST_FILE("getResponseHeader.reply"),
+ TEST_FILE("testdocument.html")));
+
+ QDeclarativeComponent component(&engine, TEST_FILE("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);
+
+ TRY_WAIT(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, TEST_FILE("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, TEST_FILE("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, TEST_FILE("getAllResponseHeaders_args.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ TRY_WAIT(object->property("exceptionThrown").toBool() == true);
+
+ delete object;
+}
+
+void tst_qdeclarativexmlhttprequest::status()
+{
+ {
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ QVERIFY(server.wait(TEST_FILE("status.expect"),
+ TEST_FILE("status.200.reply"),
+ TEST_FILE("testdocument.html")));
+
+ QDeclarativeComponent component(&engine, TEST_FILE("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", 200);
+ component.completeCreate();
+
+ TRY_WAIT(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;
+ }
+
+ {
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ QVERIFY(server.wait(TEST_FILE("status.expect"),
+ TEST_FILE("status.404.reply"),
+ TEST_FILE("testdocument.html")));
+
+ QDeclarativeComponent component(&engine, TEST_FILE("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", 404);
+ component.completeCreate();
+
+ TRY_WAIT(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()
+{
+ {
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ QVERIFY(server.wait(TEST_FILE("status.expect"),
+ TEST_FILE("status.200.reply"),
+ TEST_FILE("testdocument.html")));
+
+ QDeclarativeComponent component(&engine, TEST_FILE("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", "OK");
+ component.completeCreate();
+
+ TRY_WAIT(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;
+ }
+
+ {
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ QVERIFY(server.wait(TEST_FILE("status.expect"),
+ TEST_FILE("status.404.reply"),
+ TEST_FILE("testdocument.html")));
+
+ QDeclarativeComponent component(&engine, TEST_FILE("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", "Document not found");
+ component.completeCreate();
+
+ TRY_WAIT(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::responseText()
+{
+ {
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ QVERIFY(server.wait(TEST_FILE("status.expect"),
+ TEST_FILE("status.200.reply"),
+ TEST_FILE("testdocument.html")));
+
+ QDeclarativeComponent component(&engine, TEST_FILE("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", "QML Rocks!\n");
+ component.completeCreate();
+
+ TRY_WAIT(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;
+ }
+
+ {
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ QVERIFY(server.wait(TEST_FILE("status.expect"),
+ TEST_FILE("status.200.reply"),
+ QUrl()));
+
+ QDeclarativeComponent component(&engine, TEST_FILE("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", "");
+ component.completeCreate();
+
+ TRY_WAIT(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;
+ }
+
+ {
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ QVERIFY(server.wait(TEST_FILE("status.expect"),
+ TEST_FILE("status.404.reply"),
+ TEST_FILE("testdocument.html")));
+
+ QDeclarativeComponent component(&engine, TEST_FILE("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", "");
+ component.completeCreate();
+
+ TRY_WAIT(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;
+ }
+}
+
+// Test that calling hte XMLHttpRequest methods on a non-XMLHttpRequest object
+// throws an exception
+void tst_qdeclarativexmlhttprequest::invalidMethodUsage()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("invalidMethodUsage.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("onreadystatechange").toBool(), true);
+ 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("data");
+
+ QDeclarativeComponent component(&engine, TEST_FILE("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();
+
+ TRY_WAIT(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("data");
+
+ QDeclarativeComponent component(&engine, TEST_FILE("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();
+
+ TRY_WAIT(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("data");
+
+ QDeclarativeComponent component(&engine, TEST_FILE("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, TEST_FILE("responseXML_invalid.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ TRY_WAIT(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, TEST_FILE("document.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ TRY_WAIT(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, TEST_FILE("element.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ TRY_WAIT(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, TEST_FILE("attr.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ TRY_WAIT(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, TEST_FILE("text.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ TRY_WAIT(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, TEST_FILE("cdata.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ TRY_WAIT(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/qmlxmllistmodel/data/model.qml b/tests/auto/declarative/qdeclarativexmllistmodel/data/model.qml
index 2cbb027..2cbb027 100644
--- a/tests/auto/declarative/qmlxmllistmodel/data/model.qml
+++ b/tests/auto/declarative/qdeclarativexmllistmodel/data/model.qml
diff --git a/tests/auto/declarative/qmlxmllistmodel/data/model.xml b/tests/auto/declarative/qdeclarativexmllistmodel/data/model.xml
index 40cd6d0..40cd6d0 100644
--- a/tests/auto/declarative/qmlxmllistmodel/data/model.xml
+++ b/tests/auto/declarative/qdeclarativexmllistmodel/data/model.xml
diff --git a/tests/auto/declarative/qmlxmllistmodel/data/model2.qml b/tests/auto/declarative/qdeclarativexmllistmodel/data/model2.qml
index 140e0ad..140e0ad 100644
--- a/tests/auto/declarative/qmlxmllistmodel/data/model2.qml
+++ b/tests/auto/declarative/qdeclarativexmllistmodel/data/model2.qml
diff --git a/tests/auto/declarative/qmlxmllistmodel/data/recipes.qml b/tests/auto/declarative/qdeclarativexmllistmodel/data/recipes.qml
index 13dea91..13dea91 100644
--- a/tests/auto/declarative/qmlxmllistmodel/data/recipes.qml
+++ b/tests/auto/declarative/qdeclarativexmllistmodel/data/recipes.qml
diff --git a/tests/auto/declarative/qmlxmllistmodel/data/recipes.xml b/tests/auto/declarative/qdeclarativexmllistmodel/data/recipes.xml
index d71de60..d71de60 100644
--- a/tests/auto/declarative/qmlxmllistmodel/data/recipes.xml
+++ b/tests/auto/declarative/qdeclarativexmllistmodel/data/recipes.xml
diff --git a/tests/auto/declarative/qmlxmllistmodel/data/roleErrors.qml b/tests/auto/declarative/qdeclarativexmllistmodel/data/roleErrors.qml
index 26c533f..26c533f 100644
--- a/tests/auto/declarative/qmlxmllistmodel/data/roleErrors.qml
+++ b/tests/auto/declarative/qdeclarativexmllistmodel/data/roleErrors.qml
diff --git a/tests/auto/declarative/qdeclarativexmllistmodel/data/roleKeys.qml b/tests/auto/declarative/qdeclarativexmllistmodel/data/roleKeys.qml
new file mode 100644
index 0000000..b90e57e
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmllistmodel/data/roleKeys.qml
@@ -0,0 +1,13 @@
+import Qt 4.6
+
+XmlListModel {
+ query: "/data/item"
+ XmlRole { id: nameRole; name: "name"; query: "name/string()"; isKey: true }
+ XmlRole { name: "age"; query: "age/number()"; isKey: true }
+ XmlRole { name: "sport"; query: "sport/string()" }
+
+ function disableNameKey() {
+ nameRole.isKey = false;
+ }
+}
+
diff --git a/tests/auto/declarative/qmlxmllistmodel/data/unique.qml b/tests/auto/declarative/qdeclarativexmllistmodel/data/unique.qml
index ed0f293..ed0f293 100644
--- a/tests/auto/declarative/qmlxmllistmodel/data/unique.qml
+++ b/tests/auto/declarative/qdeclarativexmllistmodel/data/unique.qml
diff --git a/tests/auto/declarative/qdeclarativexmllistmodel/qdeclarativexmllistmodel.pro b/tests/auto/declarative/qdeclarativexmllistmodel/qdeclarativexmllistmodel.pro
new file mode 100644
index 0000000..88832dc
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmllistmodel/qdeclarativexmllistmodel.pro
@@ -0,0 +1,11 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative gui
+contains(QT_CONFIG,xmlpatterns) {
+ QT += xmlpatterns
+ DEFINES += QTEST_XMLPATTERNS
+}
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qdeclarativexmllistmodel.cpp
+
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp b/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp
new file mode 100644
index 0000000..e19e03d
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp
@@ -0,0 +1,457 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QtTest/qsignalspy.h>
+#include <QtCore/qtimer.h>
+
+#ifdef QTEST_XMLPATTERNS
+#include <QtDeclarative/qdeclarativeengine.h>
+#include <QtDeclarative/qdeclarativecomponent.h>
+#include <private/qdeclarativexmllistmodel_p.h>
+#include "../../../shared/util.h"
+
+typedef QPair<int, int> QDeclarativeXmlListRange;
+typedef QList<QVariantList> QDeclarativeXmlModelData;
+
+Q_DECLARE_METATYPE(QList<QDeclarativeXmlListRange>)
+Q_DECLARE_METATYPE(QDeclarativeXmlModelData)
+
+class tst_qdeclarativexmllistmodel : public QObject
+
+{
+ Q_OBJECT
+public:
+ tst_qdeclarativexmllistmodel() {}
+
+private slots:
+ void buildModel();
+ void missingFields();
+ void cdata();
+ void attributes();
+ void roles();
+ void roleErrors();
+ void uniqueRoleNames();
+ void useKeys();
+ void useKeys_data();
+ void noKeysValueChanges();
+ void keysChanged();
+
+private:
+ 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) {
+ QVariantList variants;
+ xml += QLatin1String("<item>");
+ QStringList fields = item.split(",");
+ foreach(const QString &field, fields) {
+ QStringList values = field.split("=");
+ Q_ASSERT(values.count() == 2);
+ 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;
+};
+
+void tst_qdeclarativexmllistmodel::buildModel()
+{
+ QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/model.qml"));
+ QDeclarativeXmlListModel *listModel = qobject_cast<QDeclarativeXmlListModel*>(component.create());
+ QVERIFY(listModel != 0);
+ QTRY_COMPARE(listModel->count(), 9);
+
+ QList<int> roles;
+ roles << Qt::UserRole << Qt::UserRole + 1 << Qt::UserRole + 2 << Qt::UserRole + 3;
+ QHash<int, QVariant> data = listModel->data(3, roles);
+ QVERIFY(data.count() == 4);
+ QCOMPARE(data.value(Qt::UserRole).toString(), QLatin1String("Spot"));
+ QCOMPARE(data.value(Qt::UserRole+1).toString(), QLatin1String("Dog"));
+ QCOMPARE(data.value(Qt::UserRole+2).toInt(), 9);
+ QCOMPARE(data.value(Qt::UserRole+3).toString(), QLatin1String("Medium"));
+
+ delete listModel;
+}
+
+void tst_qdeclarativexmllistmodel::missingFields()
+{
+ QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/model2.qml"));
+ QDeclarativeXmlListModel *listModel = qobject_cast<QDeclarativeXmlListModel*>(component.create());
+ QVERIFY(listModel != 0);
+ QTRY_COMPARE(listModel->count(), 9);
+
+ QList<int> roles;
+ roles << Qt::UserRole << Qt::UserRole + 1 << Qt::UserRole + 2 << Qt::UserRole + 3 << Qt::UserRole + 4;
+ QHash<int, QVariant> data = listModel->data(5, roles);
+ QVERIFY(data.count() == 5);
+ QCOMPARE(data.value(Qt::UserRole+3).toString(), QLatin1String(""));
+ QCOMPARE(data.value(Qt::UserRole+4).toString(), QLatin1String(""));
+
+ data = listModel->data(7, roles);
+ QVERIFY(data.count() == 5);
+ QCOMPARE(data.value(Qt::UserRole+2).toString(), QLatin1String(""));
+
+ delete listModel;
+}
+
+void tst_qdeclarativexmllistmodel::cdata()
+{
+ QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/recipes.qml"));
+ QDeclarativeXmlListModel *listModel = qobject_cast<QDeclarativeXmlListModel*>(component.create());
+ QVERIFY(listModel != 0);
+ QTRY_COMPARE(listModel->count(), 5);
+
+ QList<int> roles;
+ roles << Qt::UserRole + 2;
+ QHash<int, QVariant> data = listModel->data(2, roles);
+ QVERIFY(data.count() == 1);
+ QVERIFY(data.value(Qt::UserRole+2).toString().startsWith(QLatin1String("<html>")));
+
+ delete listModel;
+}
+
+void tst_qdeclarativexmllistmodel::attributes()
+{
+ QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/recipes.qml"));
+ QDeclarativeXmlListModel *listModel = qobject_cast<QDeclarativeXmlListModel*>(component.create());
+ QVERIFY(listModel != 0);
+ QTRY_COMPARE(listModel->count(), 5);
+
+ QList<int> roles;
+ roles << Qt::UserRole;
+ QHash<int, QVariant> data = listModel->data(2, roles);
+ QVERIFY(data.count() == 1);
+ QCOMPARE(data.value(Qt::UserRole).toString(), QLatin1String("Vegetable Soup"));
+
+ delete listModel;
+}
+
+void tst_qdeclarativexmllistmodel::roles()
+{
+ QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/model.qml"));
+ QDeclarativeXmlListModel *listModel = qobject_cast<QDeclarativeXmlListModel*>(component.create());
+ QVERIFY(listModel != 0);
+ QTRY_COMPARE(listModel->count(), 9);
+
+ QList<int> roles = listModel->roles();
+ QCOMPARE(roles.count(), 4);
+ QCOMPARE(listModel->toString(roles.at(0)), QLatin1String("name"));
+ QCOMPARE(listModel->toString(roles.at(1)), QLatin1String("type"));
+ QCOMPARE(listModel->toString(roles.at(2)), QLatin1String("age"));
+ QCOMPARE(listModel->toString(roles.at(3)), QLatin1String("size"));
+
+ delete listModel;
+}
+
+void tst_qdeclarativexmllistmodel::roleErrors()
+{
+ QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/roleErrors.qml"));
+ QTest::ignoreMessage(QtWarningMsg, QString("QML XmlRole (" + QUrl::fromLocalFile(SRCDIR "/data/roleErrors.qml").toString() + ":6:5) An XmlRole query must not start with '/'").toUtf8().constData());
+ //### make sure we receive all expected warning messages.
+ QDeclarativeXmlListModel *listModel = qobject_cast<QDeclarativeXmlListModel*>(component.create());
+ QVERIFY(listModel != 0);
+ QTRY_COMPARE(listModel->count(), 9);
+
+ QList<int> roles;
+ roles << Qt::UserRole << Qt::UserRole + 1 << Qt::UserRole + 2 << Qt::UserRole + 3;
+ QHash<int, QVariant> data = listModel->data(3, roles);
+ QVERIFY(data.count() == 4);
+
+ //### should any of these return valid values?
+ QCOMPARE(data.value(Qt::UserRole), QVariant());
+ QCOMPARE(data.value(Qt::UserRole+1), QVariant());
+ QCOMPARE(data.value(Qt::UserRole+2), QVariant());
+
+ QEXPECT_FAIL("", "QT-2456", Continue);
+ QCOMPARE(data.value(Qt::UserRole+3), QVariant());
+
+ delete listModel;
+}
+
+void tst_qdeclarativexmllistmodel::uniqueRoleNames()
+{
+ QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/unique.qml"));
+ QTest::ignoreMessage(QtWarningMsg, QString("QML XmlRole (" + QUrl::fromLocalFile(SRCDIR "/data/unique.qml").toString() + ":7:5) \"name\" duplicates a previous role name and will be disabled.").toUtf8().constData());
+ QDeclarativeXmlListModel *listModel = qobject_cast<QDeclarativeXmlListModel*>(component.create());
+ QVERIFY(listModel != 0);
+ QTRY_COMPARE(listModel->count(), 9);
+
+ QList<int> roles = listModel->roles();
+ QCOMPARE(roles.count(), 1);
+
+ delete listModel;
+}
+
+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, QUrl::fromLocalFile(SRCDIR "/data/roleKeys.qml"));
+ QDeclarativeXmlListModel *model = qobject_cast<QDeclarativeXmlListModel*>(component.create());
+ QVERIFY(model != 0);
+
+ model->setXml(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->setXml(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);
+ }
+}
+
+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")
+ << 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));
+}
+
+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, QUrl::fromLocalFile(SRCDIR "/data/roleKeys.qml"));
+ QDeclarativeXmlListModel *model = qobject_cast<QDeclarativeXmlListModel*>(component.create());
+ QVERIFY(model != 0);
+
+ QString xml;
+
+ xml = makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics");
+ model->setXml(xml);
+ QTRY_COMPARE(model->count(), 2);
+
+ 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->setXml(xml);
+
+ // wait for the new xml data to be set, and verify no signals were emitted
+ for (int i=0; i<50; i++) {
+ QTest::qWait(100);
+ if (model->data(0, model->roles()[2]).toString() != QLatin1String("AussieRules"))
+ break;
+ }
+ 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);
+}
+
+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, QUrl::fromLocalFile(SRCDIR "/data/roleKeys.qml"));
+ QDeclarativeXmlListModel *model = qobject_cast<QDeclarativeXmlListModel*>(component.create());
+ QVERIFY(model != 0);
+
+ QString xml = makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics");
+ model->setXml(xml);
+ QTRY_COMPARE(model->count(), 2);
+
+ 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->setXml(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);
+}
+
+QTEST_MAIN(tst_qdeclarativexmllistmodel)
+
+#include "tst_qdeclarativexmllistmodel.moc"
+
+#else
+QTEST_NOOP_MAIN
+#endif
diff --git a/tests/auto/declarative/qmlanimations/qmlanimations.pro b/tests/auto/declarative/qmlanimations/qmlanimations.pro
deleted file mode 100644
index 447fb0f..0000000
--- a/tests/auto/declarative/qmlanimations/qmlanimations.pro
+++ /dev/null
@@ -1,6 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative
-SOURCES += tst_qmlanimations.cpp
-macx:CONFIG -= app_bundle
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmlanimations/tst_qmlanimations.cpp b/tests/auto/declarative/qmlanimations/tst_qmlanimations.cpp
deleted file mode 100644
index 9eae308..0000000
--- a/tests/auto/declarative/qmlanimations/tst_qmlanimations.cpp
+++ /dev/null
@@ -1,672 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtDeclarative/qmlengine.h>
-#include <QtDeclarative/qmlcomponent.h>
-#include <QtDeclarative/qmlview.h>
-#include <private/qmlgraphicsrectangle_p.h>
-#include <private/qmlanimation_p.h>
-#include <QVariantAnimation>
-
-class tst_qmlanimations : public QObject
-{
- Q_OBJECT
-public:
- tst_qmlanimations() {}
-
-private slots:
- void initTestCase() { QmlEngine engine; } // ensure types are registered
-
- void simpleProperty();
- void simpleNumber();
- void simpleColor();
- void alwaysRunToEnd();
- void complete();
- void resume();
- void dotProperty();
- void badTypes();
- void badProperties();
- void mixedTypes();
- void properties();
- void propertiesTransition();
- void easingStringConversion();
- void invalidDuration();
- void attached();
- void propertyValueSourceDefaultStart();
- void dontStart();
-};
-
-#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_qmlanimations::simpleProperty()
-{
- QmlGraphicsRectangle rect;
- QmlPropertyAnimation animation;
- animation.setTarget(&rect);
- animation.setProperty("pos");
- animation.setTo(QPointF(200,200));
- QVERIFY(animation.target() == &rect);
- QVERIFY(animation.property() == "pos");
- QVERIFY(animation.to().toPointF() == QPointF(200,200));
- animation.start();
- QVERIFY(animation.isRunning());
- QTest::qWait(animation.duration());
- QTIMED_COMPARE(rect.pos(), QPointF(200,200));
-
- rect.setPos(0,0);
- animation.start();
- animation.pause();
- QVERIFY(animation.isRunning());
- QVERIFY(animation.isPaused());
- animation.setCurrentTime(125);
- QVERIFY(animation.currentTime() == 125);
- QCOMPARE(rect.pos(), QPointF(100,100));
-}
-
-void tst_qmlanimations::simpleNumber()
-{
- QmlGraphicsRectangle rect;
- QmlNumberAnimation animation;
- animation.setTarget(&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_qmlanimations::simpleColor()
-{
- QmlGraphicsRectangle rect;
- QmlColorAnimation animation;
- animation.setTarget(&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);
- 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_qmlanimations::alwaysRunToEnd()
-{
- QmlGraphicsRectangle rect;
- QmlPropertyAnimation animation;
- animation.setTarget(&rect);
- animation.setProperty("x");
- animation.setTo(200);
- animation.setDuration(1000);
- animation.setRepeat(true);
- animation.setAlwaysRunToEnd(true);
- QVERIFY(animation.repeat() == true);
- 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_qmlanimations::complete()
-{
- QmlGraphicsRectangle rect;
- QmlPropertyAnimation animation;
- animation.setTarget(&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_qmlanimations::resume()
-{
- QmlGraphicsRectangle rect;
- QmlPropertyAnimation animation;
- animation.setTarget(&rect);
- animation.setProperty("x");
- animation.setFrom(10);
- animation.setTo(200);
- animation.setDuration(500);
- QVERIFY(animation.from() == 10);
-
- animation.start();
- QTest::qWait(100);
- animation.pause();
- qreal x = rect.x();
- QVERIFY(x != qreal(200));
- QVERIFY(animation.isRunning());
- QVERIFY(animation.isPaused());
-
- animation.resume();
- QVERIFY(animation.isRunning());
- QVERIFY(!animation.isPaused());
- QTest::qWait(100);
- animation.stop();
- QVERIFY(rect.x() > x);
-}
-
-void tst_qmlanimations::dotProperty()
-{
- QmlGraphicsRectangle rect;
- QmlNumberAnimation animation;
- animation.setTarget(&rect);
- animation.setProperty("border.width");
- animation.setTo(10);
- animation.start();
- QTest::qWait(animation.duration()+50);
- QTIMED_COMPARE(rect.border()->width(), 10);
-
- rect.border()->setWidth(0);
- animation.start();
- animation.pause();
- animation.setCurrentTime(125);
- QVERIFY(animation.currentTime() == 125);
- QCOMPARE(rect.border()->width(), 5);
-}
-
-void tst_qmlanimations::badTypes()
-{
- //don't crash
- {
- QmlView *view = new QmlView;
- view->setSource(QUrl::fromLocalFile(SRCDIR "/data/badtype1.qml"));
-
- view->execute();
- qApp->processEvents();
-
- delete view;
- }
-
- //make sure we get a compiler error
- {
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/badtype2.qml"));
- QTest::ignoreMessage(QtWarningMsg, "QmlComponent: Component is not ready");
- c.create();
-
- QVERIFY(c.errors().count() == 1);
- QCOMPARE(c.errors().at(0).description(), QLatin1String("Invalid property assignment: double expected"));
- }
-
- //make sure we get a compiler error
- {
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/badtype3.qml"));
- QTest::ignoreMessage(QtWarningMsg, "QmlComponent: 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
- {
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/badtype4.qml"));
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create());
- QVERIFY(rect);
-
- rect->setState("state1");
- QTest::qWait(1000 + 50);
- QmlGraphicsRectangle *myRect = rect->findChild<QmlGraphicsRectangle*>("MyRect");
- QVERIFY(myRect);
- QCOMPARE(myRect->x(),qreal(200));
- }
-}
-
-void tst_qmlanimations::badProperties()
-{
- //make sure we get a runtime error
- {
- QmlEngine engine;
-
- QmlComponent c1(&engine, QUrl::fromLocalFile(SRCDIR "/data/badproperty1.qml"));
- QByteArray message = "QML ColorAnimation (" + QUrl::fromLocalFile(SRCDIR "/data/badproperty1.qml").toString().toUtf8() + ":18:9) Cannot animate non-existent property \"border.colr\"";
- QTest::ignoreMessage(QtWarningMsg, message);
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c1.create());
- QVERIFY(rect);
-
- QmlComponent c2(&engine, QUrl::fromLocalFile(SRCDIR "/data/badproperty2.qml"));
- message = "QML ColorAnimation (" + QUrl::fromLocalFile(SRCDIR "/data/badproperty2.qml").toString().toUtf8() + ":18:9) Cannot animate read-only property \"border\"";
- QTest::ignoreMessage(QtWarningMsg, message);
- rect = qobject_cast<QmlGraphicsRectangle*>(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_qmlanimations::mixedTypes()
-{
- //assumes border.width stays a real -- not real robust
- {
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/mixedtype1.qml"));
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create());
- QVERIFY(rect);
-
- rect->setState("state1");
- QTest::qWait(500);
- QmlGraphicsRectangle *myRect = rect->findChild<QmlGraphicsRectangle*>("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);
- }
-
- {
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/mixedtype2.qml"));
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create());
- QVERIFY(rect);
-
- rect->setState("state1");
- QTest::qWait(500);
- QmlGraphicsRectangle *myRect = rect->findChild<QmlGraphicsRectangle*>("MyRect");
- QVERIFY(myRect);
-
- //rather inexact -- is there a better way?
- QVERIFY(myRect->x() > 100 && myRect->x() < 200);
- QVERIFY(myRect->color() != QColor("red") && myRect->color() != QColor("blue"));
- }
-}
-
-void tst_qmlanimations::properties()
-{
- const int waitDuration = 300;
- {
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/properties.qml"));
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create());
- QVERIFY(rect);
-
- QmlGraphicsRectangle *myRect = rect->findChild<QmlGraphicsRectangle*>("TheRect");
- QVERIFY(myRect);
- QTest::qWait(waitDuration);
- QTIMED_COMPARE(myRect->x(),qreal(200));
- }
-
- {
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/properties2.qml"));
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create());
- QVERIFY(rect);
-
- QmlGraphicsRectangle *myRect = rect->findChild<QmlGraphicsRectangle*>("TheRect");
- QVERIFY(myRect);
- QTest::qWait(waitDuration);
- QTIMED_COMPARE(myRect->x(),qreal(200));
- }
-
- {
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/properties3.qml"));
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create());
- QVERIFY(rect);
-
- QmlGraphicsRectangle *myRect = rect->findChild<QmlGraphicsRectangle*>("TheRect");
- QVERIFY(myRect);
- QTest::qWait(waitDuration);
- QTIMED_COMPARE(myRect->x(),qreal(300));
- }
-
- {
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/properties4.qml"));
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create());
- QVERIFY(rect);
-
- QmlGraphicsRectangle *myRect = rect->findChild<QmlGraphicsRectangle*>("TheRect");
- QVERIFY(myRect);
- QTest::qWait(waitDuration);
- QTIMED_COMPARE(myRect->y(),qreal(200));
- QTIMED_COMPARE(myRect->x(),qreal(100));
- }
-
- {
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/properties5.qml"));
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create());
- QVERIFY(rect);
-
- QmlGraphicsRectangle *myRect = rect->findChild<QmlGraphicsRectangle*>("TheRect");
- QVERIFY(myRect);
- QTest::qWait(waitDuration);
- QTIMED_COMPARE(myRect->x(),qreal(100));
- QTIMED_COMPARE(myRect->y(),qreal(200));
- }
-}
-
-void tst_qmlanimations::propertiesTransition()
-{
- const int waitDuration = 300;
- {
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertiesTransition.qml"));
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create());
- QVERIFY(rect);
-
- rect->setState("moved");
- QmlGraphicsRectangle *myRect = rect->findChild<QmlGraphicsRectangle*>("TheRect");
- QVERIFY(myRect);
- QTest::qWait(waitDuration);
- QTIMED_COMPARE(myRect->x(),qreal(200));
- }
-
- {
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertiesTransition2.qml"));
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create());
- QVERIFY(rect);
-
- QmlGraphicsRectangle *myRect = rect->findChild<QmlGraphicsRectangle*>("TheRect");
- QVERIFY(myRect);
- rect->setState("moved");
- QCOMPARE(myRect->x(),qreal(200));
- QCOMPARE(myRect->y(),qreal(100));
- QTest::qWait(waitDuration);
- QTIMED_COMPARE(myRect->y(),qreal(200));
- }
-
- {
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertiesTransition3.qml"));
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create());
- QVERIFY(rect);
-
- QmlGraphicsRectangle *myRect = rect->findChild<QmlGraphicsRectangle*>("TheRect");
- QVERIFY(myRect);
- rect->setState("moved");
- QCOMPARE(myRect->x(),qreal(200));
- QCOMPARE(myRect->y(),qreal(100));
- }
-
- {
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertiesTransition4.qml"));
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create());
- QVERIFY(rect);
-
- QmlGraphicsRectangle *myRect = rect->findChild<QmlGraphicsRectangle*>("TheRect");
- QVERIFY(myRect);
- rect->setState("moved");
- QCOMPARE(myRect->x(),qreal(100));
- QTest::qWait(waitDuration);
- QTIMED_COMPARE(myRect->x(),qreal(200));
- }
-
- {
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertiesTransition5.qml"));
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create());
- QVERIFY(rect);
-
- QmlGraphicsRectangle *myRect = rect->findChild<QmlGraphicsRectangle*>("TheRect");
- QVERIFY(myRect);
- rect->setState("moved");
- QCOMPARE(myRect->x(),qreal(100));
- QTest::qWait(waitDuration);
- QTIMED_COMPARE(myRect->x(),qreal(200));
- }
-
- /*{
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertiesTransition6.qml"));
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create());
- QVERIFY(rect);
-
- QmlGraphicsRectangle *myRect = rect->findChild<QmlGraphicsRectangle*>("TheRect");
- QVERIFY(myRect);
- rect->setState("moved");
- QCOMPARE(myRect->x(),qreal(100));
- QTest::qWait(waitDuration);
- QTIMED_COMPARE(myRect->x(),qreal(100));
- }*/
-}
-
-void tst_qmlanimations::easingStringConversion()
-{
- QmlNumberAnimation *animation = new QmlNumberAnimation;
- animation->setEasing("easeInOutQuad");
- QCOMPARE(animation->easing(),QLatin1String("easeInOutQuad"));
- QCOMPARE(static_cast<QVariantAnimation*>(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve(), QEasingCurve(QEasingCurve::InOutQuad));
-
- animation->setEasing("OutQuad");
- QCOMPARE(static_cast<QVariantAnimation*>(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve(), QEasingCurve(QEasingCurve::OutQuad));
-
- animation->setEasing("easeOutBounce(amplitude: 5)");
- QCOMPARE(static_cast<QVariantAnimation*>(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve().type(), QEasingCurve::OutBounce);
- QCOMPARE(static_cast<QVariantAnimation*>(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve().amplitude(), qreal(5));
-
- animation->setEasing("easeOutElastic(amplitude: 5, period: 3)");
- QCOMPARE(static_cast<QVariantAnimation*>(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve().type(), QEasingCurve::OutElastic);
- QCOMPARE(static_cast<QVariantAnimation*>(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve().amplitude(), qreal(5));
- QCOMPARE(static_cast<QVariantAnimation*>(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve().period(), qreal(3));
-
- animation->setEasing("easeInOutBack(overshoot: 2)");
- QCOMPARE(static_cast<QVariantAnimation*>(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve().type(), QEasingCurve::InOutBack);
- QCOMPARE(static_cast<QVariantAnimation*>(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve().overshoot(), qreal(2));
-
- QTest::ignoreMessage(QtWarningMsg, "QML NumberAnimation (unknown location) Unmatched parenthesis in easing function \"easeInOutBack(overshoot: 2\"");
- animation->setEasing("easeInOutBack(overshoot: 2");
- QCOMPARE(static_cast<QVariantAnimation*>(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve().type(), QEasingCurve::Linear);
-
- QTest::ignoreMessage(QtWarningMsg, "QML NumberAnimation (unknown location) Easing function \"InOutBack(overshoot: 2)\" must start with \"ease\"");
- animation->setEasing("InOutBack(overshoot: 2)");
- QCOMPARE(static_cast<QVariantAnimation*>(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve().type(), QEasingCurve::Linear);
-
- QTest::ignoreMessage(QtWarningMsg, "QML NumberAnimation (unknown location) Unknown easing curve \"NonExistantEase\"");
- animation->setEasing("NonExistantEase");
- QCOMPARE(static_cast<QVariantAnimation*>(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve().type(), QEasingCurve::Linear);
-
- QTest::ignoreMessage(QtWarningMsg, "QML NumberAnimation (unknown location) Improperly specified parameter in easing function \"easeInOutElastic(amplitude 5)\"");
- animation->setEasing("easeInOutElastic(amplitude 5)");
- QCOMPARE(static_cast<QVariantAnimation*>(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve().type(), QEasingCurve::InOutElastic);
-
- QTest::ignoreMessage(QtWarningMsg, "QML NumberAnimation (unknown location) Improperly specified parameter in easing function \"easeInOutElastic(amplitude: yes)\"");
- animation->setEasing("easeInOutElastic(amplitude: yes)");
- QCOMPARE(static_cast<QVariantAnimation*>(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve().type(), QEasingCurve::InOutElastic);
- QVERIFY(static_cast<QVariantAnimation*>(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve().amplitude() != qreal(5));
-
- QTest::ignoreMessage(QtWarningMsg, "QML NumberAnimation (unknown location) Unknown easing parameter \"nonexistentproperty\"");
- animation->setEasing("easeOutQuad(nonexistentproperty: 12)");
- QCOMPARE(static_cast<QVariantAnimation*>(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve().type(), QEasingCurve::OutQuad);
-
- delete animation;
-}
-
-void tst_qmlanimations::invalidDuration()
-{
- QmlPropertyAnimation *animation = new QmlPropertyAnimation;
- QTest::ignoreMessage(QtWarningMsg, "QML PropertyAnimation (unknown location) Cannot set a duration of < 0");
- animation->setDuration(-1);
- QCOMPARE(animation->duration(), 250);
-
- QmlPauseAnimation *pauseAnimation = new QmlPauseAnimation;
- QTest::ignoreMessage(QtWarningMsg, "QML PauseAnimation (unknown location) Cannot set a duration of < 0");
- pauseAnimation->setDuration(-1);
- QCOMPARE(pauseAnimation->duration(), 250);
-}
-
-void tst_qmlanimations::attached()
-{
- QmlEngine engine;
-
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/attached.qml"));
- QTest::ignoreMessage(QtDebugMsg, "off");
- QTest::ignoreMessage(QtDebugMsg, "on");
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create());
- QVERIFY(rect);
-}
-
-void tst_qmlanimations::propertyValueSourceDefaultStart()
-{
- {
- QmlEngine engine;
-
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/valuesource.qml"));
-
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create());
- QVERIFY(rect);
-
- QmlAbstractAnimation *myAnim = rect->findChild<QmlAbstractAnimation*>("MyAnim");
- QVERIFY(myAnim);
- QVERIFY(myAnim->isRunning());
- }
-
- {
- QmlEngine engine;
-
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/valuesource2.qml"));
-
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create());
- QVERIFY(rect);
-
- QmlAbstractAnimation *myAnim = rect->findChild<QmlAbstractAnimation*>("MyAnim");
- QVERIFY(myAnim);
- QVERIFY(myAnim->isRunning() == false);
- }
-
- {
- QmlEngine engine;
-
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/dontAutoStart.qml"));
-
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create());
- QVERIFY(rect);
-
- QmlAbstractAnimation *myAnim = rect->findChild<QmlAbstractAnimation*>("MyAnim");
- QVERIFY(myAnim && myAnim->qtAnimation());
- QVERIFY(myAnim->qtAnimation()->state() == QAbstractAnimation::Stopped);
- }
-}
-
-
-void tst_qmlanimations::dontStart()
-{
- {
- QmlEngine engine;
-
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/dontStart.qml"));
-
- QTest::ignoreMessage(QtWarningMsg, "QmlAbstractAnimation: setRunning() cannot be used on non-root animation nodes");
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create());
- QVERIFY(rect);
-
- QmlAbstractAnimation *myAnim = rect->findChild<QmlAbstractAnimation*>("MyAnim");
- QVERIFY(myAnim && myAnim->qtAnimation());
- QVERIFY(myAnim->qtAnimation()->state() == QAbstractAnimation::Stopped);
- }
-
- {
- QmlEngine engine;
-
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/dontStart2.qml"));
-
- QTest::ignoreMessage(QtWarningMsg, "QmlAbstractAnimation: setRunning() cannot be used on non-root animation nodes");
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create());
- QVERIFY(rect);
-
- QmlAbstractAnimation *myAnim = rect->findChild<QmlAbstractAnimation*>("MyAnim");
- QVERIFY(myAnim && myAnim->qtAnimation());
- QVERIFY(myAnim->qtAnimation()->state() == QAbstractAnimation::Stopped);
- }
-}
-
-QTEST_MAIN(tst_qmlanimations)
-
-#include "tst_qmlanimations.moc"
diff --git a/tests/auto/declarative/qmlbehaviors/qmlbehaviors.pro b/tests/auto/declarative/qmlbehaviors/qmlbehaviors.pro
deleted file mode 100644
index 1e685ee..0000000
--- a/tests/auto/declarative/qmlbehaviors/qmlbehaviors.pro
+++ /dev/null
@@ -1,6 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative
-SOURCES += tst_qmlbehaviors.cpp
-macx:CONFIG -= app_bundle
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmlbehaviors/tst_qmlbehaviors.cpp b/tests/auto/declarative/qmlbehaviors/tst_qmlbehaviors.cpp
deleted file mode 100644
index e31b600..0000000
--- a/tests/auto/declarative/qmlbehaviors/tst_qmlbehaviors.cpp
+++ /dev/null
@@ -1,301 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtDeclarative/qmlengine.h>
-#include <QtDeclarative/qmlcomponent.h>
-#include <QtDeclarative/qmlview.h>
-#include <private/qmlgraphicsrectangle_p.h>
-#include <private/qmlbehavior_p.h>
-#include <private/qmlanimation_p.h>
-
-class tst_qmlbehaviors : public QObject
-{
- Q_OBJECT
-public:
- tst_qmlbehaviors() {}
-
-private slots:
- void simpleBehavior();
- void scriptTriggered();
- void cppTriggered();
- void loop();
- void colorBehavior();
- void parentBehavior();
- void replaceBinding();
- //void transitionOverrides();
- void group();
- void emptyBehavior();
- void explicitSelection();
- void nonSelectingBehavior();
- void reassignedAnimation();
- void disabled();
- void dontStart();
-};
-
-void tst_qmlbehaviors::simpleBehavior()
-{
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/simple.qml"));
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create());
- QVERIFY(rect);
- QVERIFY(qobject_cast<QmlBehavior*>(rect->findChild<QmlBehavior*>("MyBehavior"))->animation());
-
- rect->setState("moved");
- QTest::qWait(200);
- qreal x = qobject_cast<QmlGraphicsRectangle*>(rect->findChild<QmlGraphicsRectangle*>("MyRect"))->x();
- QVERIFY(x > 0 && x < 200); //i.e. the behavior has been triggered
-}
-
-void tst_qmlbehaviors::scriptTriggered()
-{
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/scripttrigger.qml"));
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create());
- QVERIFY(rect);
-
- rect->setColor(QColor("red"));
- QTest::qWait(200);
- qreal x = qobject_cast<QmlGraphicsRectangle*>(rect->findChild<QmlGraphicsRectangle*>("MyRect"))->x();
- QVERIFY(x > 0 && x < 200); //i.e. the behavior has been triggered
-}
-
-void tst_qmlbehaviors::cppTriggered()
-{
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/cpptrigger.qml"));
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create());
- QVERIFY(rect);
-
- QmlGraphicsRectangle *innerRect = qobject_cast<QmlGraphicsRectangle*>(rect->findChild<QmlGraphicsRectangle*>("MyRect"));
- QVERIFY(innerRect);
-
- innerRect->setProperty("x", 200);
- QTest::qWait(200);
- qreal x = innerRect->x();
- QVERIFY(x > 0 && x < 200); //i.e. the behavior has been triggered
-}
-
-void tst_qmlbehaviors::loop()
-{
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/loop.qml"));
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create());
- QVERIFY(rect);
-
- //don't crash
- rect->setState("moved");
-}
-
-void tst_qmlbehaviors::colorBehavior()
-{
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/color.qml"));
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create());
- QVERIFY(rect);
-
- rect->setState("red");
- QTest::qWait(200);
- QColor color = qobject_cast<QmlGraphicsRectangle*>(rect->findChild<QmlGraphicsRectangle*>("MyRect"))->color();
- QVERIFY(color != QColor("red") && color != QColor("green")); //i.e. the behavior has been triggered
-}
-
-void tst_qmlbehaviors::parentBehavior()
-{
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/parent.qml"));
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create());
- QVERIFY(rect);
-
- rect->setState("reparented");
- QTest::qWait(200);
- QmlGraphicsItem *newParent = rect->findChild<QmlGraphicsItem*>("NewParent");
- QmlGraphicsItem *parent = rect->findChild<QmlGraphicsRectangle*>("MyRect")->parentItem();
- QVERIFY(parent != newParent);
- QTest::qWait(600);
- parent = rect->findChild<QmlGraphicsRectangle*>("MyRect")->parentItem();
- QVERIFY(parent == newParent);
-}
-
-void tst_qmlbehaviors::replaceBinding()
-{
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/binding.qml"));
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create());
- QVERIFY(rect);
-
- rect->setState("moved");
- QTest::qWait(200);
- QmlGraphicsRectangle *innerRect = qobject_cast<QmlGraphicsRectangle*>(rect->findChild<QmlGraphicsRectangle*>("MyRect"));
- QVERIFY(innerRect);
- qreal x = innerRect->x();
- QVERIFY(x > 0 && x < 200); //i.e. the behavior has been triggered
- QTest::qWait(600);
- QCOMPARE(innerRect->x(), (qreal)200);
- rect->setProperty("basex", 10);
- QCOMPARE(innerRect->x(), (qreal)200);
- rect->setProperty("movedx", 210);
- QTest::qWait(600);
- QCOMPARE(innerRect->x(), (qreal)210);
-
- rect->setState("");
- QTest::qWait(200);
- x = innerRect->x();
- QVERIFY(x > 10 && x < 210); //i.e. the behavior has been triggered
- QTest::qWait(600);
- QCOMPARE(innerRect->x(), (qreal)10);
- rect->setProperty("movedx", 200);
- QCOMPARE(innerRect->x(), (qreal)10);
- rect->setProperty("basex", 20);
- QTest::qWait(600);
- QCOMPARE(innerRect->x(), (qreal)20);
-}
-
-void tst_qmlbehaviors::group()
-{
- {
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/groupProperty.qml"));
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create());
- QVERIFY(rect);
-
- rect->setState("moved");
- QTest::qWait(200);
- qreal x = qobject_cast<QmlGraphicsRectangle*>(rect->findChild<QmlGraphicsRectangle*>("MyRect"))->x();
- QVERIFY(x > 0 && x < 200); //i.e. the behavior has been triggered
- }
-
- {
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/groupProperty2.qml"));
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create());
- QVERIFY(rect);
-
- rect->setState("moved");
- QTest::qWait(200);
- qreal x = qobject_cast<QmlGraphicsRectangle*>(rect->findChild<QmlGraphicsRectangle*>("MyRect"))->x();
- QVERIFY(x > 0 && x < 200); //i.e. the behavior has been triggered
- }
-}
-
-void tst_qmlbehaviors::emptyBehavior()
-{
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/empty.qml"));
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create());
- QVERIFY(rect);
-
- rect->setState("moved");
- qreal x = qobject_cast<QmlGraphicsRectangle*>(rect->findChild<QmlGraphicsRectangle*>("MyRect"))->x();
- QCOMPARE(x, qreal(200)); //should change immediately
-}
-
-void tst_qmlbehaviors::explicitSelection()
-{
- {
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/explicit.qml"));
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create());
- QVERIFY(rect);
-
- rect->setState("moved");
- QTest::qWait(200);
- qreal x = qobject_cast<QmlGraphicsRectangle*>(rect->findChild<QmlGraphicsRectangle*>("MyRect"))->x();
- QVERIFY(x > 0 && x < 200); //i.e. the behavior has been triggered
- }
-}
-
-void tst_qmlbehaviors::nonSelectingBehavior()
-{
- {
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/nonSelecting2.qml"));
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create());
- QVERIFY(rect);
-
- rect->setState("moved");
- qreal x = qobject_cast<QmlGraphicsRectangle*>(rect->findChild<QmlGraphicsRectangle*>("MyRect"))->x();
- QCOMPARE(x, qreal(200)); //should change immediately
- }
-}
-
-void tst_qmlbehaviors::reassignedAnimation()
-{
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/reassignedAnimation.qml"));
- QTest::ignoreMessage(QtWarningMsg, QString("QML Behavior (" + QUrl::fromLocalFile(SRCDIR "/data/reassignedAnimation.qml").toString() + ":9:12) Cannot change the animation assigned to a Behavior.").toUtf8().constData());
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create());
- QVERIFY(rect);
- QCOMPARE(qobject_cast<QmlNumberAnimation*>(
- qobject_cast<QmlBehavior*>(
- rect->findChild<QmlBehavior*>("MyBehavior"))->animation())->duration(), 200);
-}
-
-void tst_qmlbehaviors::disabled()
-{
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/disabled.qml"));
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create());
- QVERIFY(rect);
- QCOMPARE(rect->findChild<QmlBehavior*>("MyBehavior")->enabled(), false);
-
- rect->setState("moved");
- qreal x = qobject_cast<QmlGraphicsRectangle*>(rect->findChild<QmlGraphicsRectangle*>("MyRect"))->x();
- QCOMPARE(x, qreal(200)); //should change immediately
-}
-
-void tst_qmlbehaviors::dontStart()
-{
- QmlEngine engine;
-
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/dontStart.qml"));
-
- QTest::ignoreMessage(QtWarningMsg, "QmlAbstractAnimation: setRunning() cannot be used on non-root animation nodes");
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create());
- QVERIFY(rect);
-
- QmlAbstractAnimation *myAnim = rect->findChild<QmlAbstractAnimation*>("MyAnim");
- QVERIFY(myAnim && myAnim->qtAnimation());
- QVERIFY(myAnim->qtAnimation()->state() == QAbstractAnimation::Stopped);
-}
-
-QTEST_MAIN(tst_qmlbehaviors)
-
-#include "tst_qmlbehaviors.moc"
diff --git a/tests/auto/declarative/qmlbinding/qmlbinding.pro b/tests/auto/declarative/qmlbinding/qmlbinding.pro
deleted file mode 100644
index dfaca91..0000000
--- a/tests/auto/declarative/qmlbinding/qmlbinding.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative gui
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qmlbinding.cpp
-
-# Define SRCDIR equal to test's source directory
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmlbinding/tst_qmlbinding.cpp b/tests/auto/declarative/qmlbinding/tst_qmlbinding.cpp
deleted file mode 100644
index 92d1b69..0000000
--- a/tests/auto/declarative/qmlbinding/tst_qmlbinding.cpp
+++ /dev/null
@@ -1,107 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtDeclarative/qmlengine.h>
-#include <QtDeclarative/qmlcomponent.h>
-#include <private/qmlbind_p.h>
-#include <private/qmlgraphicsrectangle_p.h>
-#include "../../../shared/util.h"
-
-class tst_qmlbinding : public QObject
-
-{
- Q_OBJECT
-public:
- tst_qmlbinding();
-
-private slots:
- void binding();
- void whenAfterValue();
-
-private:
- QmlEngine engine;
-};
-
-tst_qmlbinding::tst_qmlbinding()
-{
-}
-
-void tst_qmlbinding::binding()
-{
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/test-binding.qml"));
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(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"));
-
- QmlBind *binding = qobject_cast<QmlBind*>(rect->findChild<QmlBind*>("binding1"));
- QVERIFY(binding != 0);
- QCOMPARE(binding->object(), rect);
- QCOMPARE(binding->property(), QLatin1String("text"));
- QCOMPARE(binding->value().toString(), QLatin1String("Hello"));
-
- delete rect;
-}
-
-void tst_qmlbinding::whenAfterValue()
-{
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/test-binding2.qml"));
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(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;
-}
-
-QTEST_MAIN(tst_qmlbinding)
-
-#include "tst_qmlbinding.moc"
diff --git a/tests/auto/declarative/qmlconnection/data/test-connection.qml b/tests/auto/declarative/qmlconnection/data/test-connection.qml
deleted file mode 100644
index 9534621..0000000
--- a/tests/auto/declarative/qmlconnection/data/test-connection.qml
+++ /dev/null
@@ -1,10 +0,0 @@
-import Qt 4.6
-
-Item {
- id: screen; width: 50
-
- property bool tested: false
- signal testMe
-
- Connection { sender: screen; signal: "widthChanged()"; script: screen.tested = true }
-}
diff --git a/tests/auto/declarative/qmlconnection/data/test-connection2.qml b/tests/auto/declarative/qmlconnection/data/test-connection2.qml
deleted file mode 100644
index 65fe23a..0000000
--- a/tests/auto/declarative/qmlconnection/data/test-connection2.qml
+++ /dev/null
@@ -1,3 +0,0 @@
-import Qt 4.6
-
-Connection { id: connection; sender: connection; signal: "widthChanged()"; script: 1 == 1 }
diff --git a/tests/auto/declarative/qmlconnection/data/test-connection3.qml b/tests/auto/declarative/qmlconnection/data/test-connection3.qml
deleted file mode 100644
index 32133f9..0000000
--- a/tests/auto/declarative/qmlconnection/data/test-connection3.qml
+++ /dev/null
@@ -1,3 +0,0 @@
-import Qt 4.6
-
-Connection {}
diff --git a/tests/auto/declarative/qmlconnection/data/trimming.qml b/tests/auto/declarative/qmlconnection/data/trimming.qml
deleted file mode 100644
index c27dc46..0000000
--- a/tests/auto/declarative/qmlconnection/data/trimming.qml
+++ /dev/null
@@ -1,10 +0,0 @@
-import Qt 4.6
-
-Item {
- id: screen; width: 50
-
- property string tested
- signal testMe(int param1, string param2)
-
- Connection { sender: screen; signal: "testMe(param1, param2)"; script: screen.tested = param2 + param1 }
-}
diff --git a/tests/auto/declarative/qmlconnection/qmlconnection.pro b/tests/auto/declarative/qmlconnection/qmlconnection.pro
deleted file mode 100644
index 3d46fa6..0000000
--- a/tests/auto/declarative/qmlconnection/qmlconnection.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative gui
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qmlconnection.cpp
-
-# Define SRCDIR equal to test's source directory
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmlconnection/tst_qmlconnection.cpp b/tests/auto/declarative/qmlconnection/tst_qmlconnection.cpp
deleted file mode 100644
index 2aba7b5..0000000
--- a/tests/auto/declarative/qmlconnection/tst_qmlconnection.cpp
+++ /dev/null
@@ -1,139 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtDeclarative/qmlengine.h>
-#include <QtDeclarative/qmlcomponent.h>
-#include <private/qmlconnection_p.h>
-#include <private/qmlgraphicsitem_p.h>
-#include "../../../shared/util.h"
-#include <QtDeclarative/qmlscriptstring.h>
-
-class tst_qmlconnection : public QObject
-
-{
- Q_OBJECT
-public:
- tst_qmlconnection();
-
-private slots:
- void defaultValues();
- void properties();
- void connection();
- void trimming();
-
-private:
- QmlEngine engine;
-};
-
-tst_qmlconnection::tst_qmlconnection()
-{
-}
-
-void tst_qmlconnection::defaultValues()
-{
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/test-connection3.qml"));
- QmlConnection *item = qobject_cast<QmlConnection*>(c.create());
-
- QVERIFY(item != 0);
- QVERIFY(item->signalSender() == 0);
- QCOMPARE(item->script().script(), QString());
- QCOMPARE(item->signal(), QString());
-
- delete item;
-}
-
-void tst_qmlconnection::properties()
-{
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/test-connection2.qml"));
- QmlConnection *item = qobject_cast<QmlConnection*>(c.create());
-
- QVERIFY(item != 0);
-
- QVERIFY(item != 0);
- QVERIFY(item->signalSender() == item);
- QCOMPARE(item->script().script(), QString("1 == 1"));
- QCOMPARE(item->signal(), QString("widthChanged()"));
-
- delete item;
-}
-
-void tst_qmlconnection::connection()
-{
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/test-connection.qml"));
- QmlGraphicsItem *item = qobject_cast<QmlGraphicsItem*>(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_qmlconnection::trimming()
-{
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/trimming.qml"));
- QmlGraphicsItem *item = qobject_cast<QmlGraphicsItem*>(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;
-}
-
-QTEST_MAIN(tst_qmlconnection)
-
-#include "tst_qmlconnection.moc"
diff --git a/tests/auto/declarative/qmlcontext/qmlcontext.pro b/tests/auto/declarative/qmlcontext/qmlcontext.pro
deleted file mode 100644
index 9e66429..0000000
--- a/tests/auto/declarative/qmlcontext/qmlcontext.pro
+++ /dev/null
@@ -1,6 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative
-SOURCES += tst_qmlcontext.cpp
-macx:CONFIG -= app_bundle
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmlcontext/tst_qmlcontext.cpp b/tests/auto/declarative/qmlcontext/tst_qmlcontext.cpp
deleted file mode 100644
index 7ff7af2..0000000
--- a/tests/auto/declarative/qmlcontext/tst_qmlcontext.cpp
+++ /dev/null
@@ -1,434 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qtest.h>
-#include <QDebug>
-#include <QmlEngine>
-#include <QmlContext>
-#include <QmlComponent>
-#include <QmlExpression>
-
-class tst_qmlcontext : public QObject
-{
- Q_OBJECT
-public:
- tst_qmlcontext() {}
-
-private slots:
- void baseUrl();
- void resolvedUrl();
- void engineMethod();
- void parentContext();
- void setContextProperty();
- void addDefaultObject();
- void destruction();
-
-private:
- QmlEngine engine;
-};
-
-void tst_qmlcontext::baseUrl()
-{
- QmlContext ctxt(&engine);
-
- QCOMPARE(ctxt.baseUrl(), QUrl());
-
- ctxt.setBaseUrl(QUrl("http://www.nokia.com/"));
-
- QCOMPARE(ctxt.baseUrl(), QUrl("http://www.nokia.com/"));
-}
-
-void tst_qmlcontext::resolvedUrl()
-{
- // Relative to the component
- {
- QmlContext 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
- {
- QmlContext ctxt(&engine);
- ctxt.setBaseUrl(QUrl("http://www.nokia.com/"));
-
- QmlContext ctxt2(&ctxt);
- QCOMPARE(ctxt2.resolvedUrl(QUrl("main2.qml")), QUrl("http://www.nokia.com/main2.qml"));
- }
-
- // Relative to the engine
- {
- QmlContext ctxt(&engine);
- QCOMPARE(ctxt.resolvedUrl(QUrl("main.qml")), engine.baseUrl().resolved(QUrl("main.qml")));
- }
-
- // Relative to a deleted parent
- {
- QmlContext *ctxt = new QmlContext(&engine);
- ctxt->setBaseUrl(QUrl("http://www.nokia.com/"));
-
- QmlContext 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
- {
- QmlContext 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_qmlcontext::engineMethod()
-{
- QmlEngine *engine = new QmlEngine;
-
- QmlContext ctxt(engine);
- QmlContext ctxt2(&ctxt);
- QmlContext ctxt3(&ctxt2);
- QmlContext 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_qmlcontext::parentContext()
-{
- QmlEngine *engine = new QmlEngine;
-
- QCOMPARE(engine->rootContext()->parentContext(), (QmlContext *)0);
-
- QmlContext *ctxt = new QmlContext(engine);
- QmlContext *ctxt2 = new QmlContext(ctxt);
- QmlContext *ctxt3 = new QmlContext(ctxt2);
- QmlContext *ctxt4 = new QmlContext(ctxt2);
- QmlContext *ctxt5 = new QmlContext(ctxt);
- QmlContext *ctxt6 = new QmlContext(engine);
- QmlContext *ctxt7 = new QmlContext(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(), ctxt2);
- QCOMPARE(ctxt4->parentContext(), ctxt2);
- QCOMPARE(ctxt5->parentContext(), ctxt);
- QCOMPARE(ctxt6->parentContext(), engine->rootContext());
- QCOMPARE(ctxt7->parentContext(), engine->rootContext());
-
- delete engine; engine = 0;
-
- QCOMPARE(ctxt->parentContext(), (QmlContext *)0);
- QCOMPARE(ctxt3->parentContext(), ctxt2);
- QCOMPARE(ctxt4->parentContext(), ctxt2);
- QCOMPARE(ctxt5->parentContext(), ctxt);
- QCOMPARE(ctxt6->parentContext(), (QmlContext *)0);
- QCOMPARE(ctxt7->parentContext(), (QmlContext *)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;
-};
-
-class TestObject2 : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(int b READ b NOTIFY bChanged)
-
-public:
- TestObject2() : _b(10) {}
-
- int b() const { return _b; }
- void setB(int b) { _b = b; emit bChanged(); }
-
-signals:
- void bChanged();
-
-private:
- int _b;
-};
-
-#define TEST_CONTEXT_PROPERTY(ctxt, name, value) \
-{ \
- QmlComponent component(&engine); \
- component.setData("import Qt 4.6; QtObject { property var test: " #name " }", QUrl()); \
-\
- QObject *obj = component.create(ctxt); \
-\
- QCOMPARE(obj->property("test"), value); \
-\
- delete obj; \
-}
-
-void tst_qmlcontext::setContextProperty()
-{
- QmlContext ctxt(&engine);
- QmlContext 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
- {
- QmlComponent component(&engine);
- component.setData("import Qt 4.6; QtObject { property var 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;
- }
- {
- QmlComponent component(&engine);
- component.setData("import Qt 4.6; QtObject { property var 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;
- }
- {
- QmlComponent component(&engine);
- component.setData("import Qt 4.6; QtObject { property var 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
- {
- QmlComponent component(&engine);
- component.setData("import Qt 4.6; QtObject { property var 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
- {
- QmlComponent component(&engine);
- component.setData("import Qt 4.6; QtObject { id: root; property int a: 10; property int test: ctxtProp.a; property var obj: root; }", QUrl());
-
- QmlContext ctxt(engine.rootContext());
- ctxt.setContextProperty("ctxtProp", QVariant());
-
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>:1: TypeError: Result of expression 'ctxtProp' [undefined] is not an object.");
- QObject *obj = component.create(&ctxt);
-
- QVariant v = obj->property("obj");
-
- ctxt.setContextProperty("ctxtProp", v);
-
- QCOMPARE(obj->property("test"), QVariant(10));
-
- delete obj;
- }
-}
-
-void tst_qmlcontext::addDefaultObject()
-{
- QmlContext ctxt(&engine);
-
- TestObject to;
- TestObject2 to2;
-
- to.setA(2);
- to.setB(192);
- to.setC(18);
- to2.setB(111999);
-
- ctxt.addDefaultObject(&to2);
- ctxt.addDefaultObject(&to);
- ctxt.setContextProperty("c", QVariant(9));
-
- // Static context properties
- TEST_CONTEXT_PROPERTY(&ctxt, a, QVariant(2));
- TEST_CONTEXT_PROPERTY(&ctxt, b, QVariant(111999));
- TEST_CONTEXT_PROPERTY(&ctxt, c, QVariant(9));
-
- to.setA(12);
- to.setB(100);
- to.setC(7);
- to2.setB(1612);
- ctxt.setContextProperty("c", QVariant(3));
-
- TEST_CONTEXT_PROPERTY(&ctxt, a, QVariant(12));
- TEST_CONTEXT_PROPERTY(&ctxt, b, QVariant(1612));
- TEST_CONTEXT_PROPERTY(&ctxt, c, QVariant(3));
-
- // Changes in context properties
- {
- QmlComponent component(&engine);
- component.setData("import Qt 4.6; QtObject { property var 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_qmlcontext::destruction()
-{
- QmlContext *ctxt = new QmlContext(&engine);
-
- QObject obj;
- QmlEngine::setContextForObject(&obj, ctxt);
- QmlExpression expr(ctxt, "a", 0);
-
- QCOMPARE(ctxt, QmlEngine::contextForObject(&obj));
- QCOMPARE(ctxt, expr.context());
-
- delete ctxt; ctxt = 0;
-
- QCOMPARE(ctxt, QmlEngine::contextForObject(&obj));
- QCOMPARE(ctxt, expr.context());
-}
-
-QTEST_MAIN(tst_qmlcontext)
-
-#include "tst_qmlcontext.moc"
diff --git a/tests/auto/declarative/qmldatetimeformatter/qmldatetimeformatter.pro b/tests/auto/declarative/qmldatetimeformatter/qmldatetimeformatter.pro
deleted file mode 100644
index 2b1947d..0000000
--- a/tests/auto/declarative/qmldatetimeformatter/qmldatetimeformatter.pro
+++ /dev/null
@@ -1,5 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qmldatetimeformatter.cpp
diff --git a/tests/auto/declarative/qmldatetimeformatter/tst_qmldatetimeformatter.cpp b/tests/auto/declarative/qmldatetimeformatter/tst_qmldatetimeformatter.cpp
deleted file mode 100644
index 4b5dc1d..0000000
--- a/tests/auto/declarative/qmldatetimeformatter/tst_qmldatetimeformatter.cpp
+++ /dev/null
@@ -1,150 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtDeclarative/qmlengine.h>
-#include <QtDeclarative/qmlcomponent.h>
-#include <private/qmldatetimeformatter_p.h>
-#include <QDebug>
-
-class tst_qmldatetimeformatter : public QObject
-{
- Q_OBJECT
-public:
- tst_qmldatetimeformatter() {}
-
-private slots:
- void date();
- void time();
- void dateTime();
-};
-
-void tst_qmldatetimeformatter::date()
-{
- QmlEngine engine;
- QmlComponent formatterComponent(&engine);
- formatterComponent.setData(QByteArray("import Qt 4.6\n DateTimeFormatter { date: \"2008-12-24\" }"),
- QUrl::fromLocalFile(""));
- QmlDateTimeFormatter *formatter = qobject_cast<QmlDateTimeFormatter*>(formatterComponent.create());
- if(formatterComponent.isError())
- qDebug() << formatterComponent.errors();
- QVERIFY(formatter != 0);
-
- QDate date(2008,12,24);
- QCOMPARE(formatter->date(), date);
- QCOMPARE(formatter->dateTime().date(), date);
- QCOMPARE(formatter->dateText(),date.toString(Qt::SystemLocaleShortDate));
-
- formatter->setLongStyle(true);
- QVERIFY(formatter->longStyle());
- QCOMPARE(formatter->dateText(),date.toString(Qt::SystemLocaleLongDate));
-
- formatter->setDateFormat("ddd MMMM d yy");
- QCOMPARE(formatter->dateFormat(), QLatin1String("ddd MMMM d yy"));
- QCOMPARE(formatter->dateText(),date.toString("ddd MMMM d yy"));
-
- QVERIFY(formatter->timeText().isEmpty());
- QVERIFY(formatter->dateTimeText().isEmpty());
-
- delete formatter;
-}
-
-void tst_qmldatetimeformatter::time()
-{
- QmlEngine engine;
- QmlComponent formatterComponent(&engine);
- formatterComponent.setData("import Qt 4.6\n DateTimeFormatter { time: \"14:15:38.200\" }", QUrl::fromLocalFile(""));
- QmlDateTimeFormatter *formatter = qobject_cast<QmlDateTimeFormatter*>(formatterComponent.create());
- if(formatterComponent.isError())
- qDebug() << formatterComponent.errors();
- QVERIFY(formatter != 0);
-
- QTime time(14,15,38,200);
-
- QCOMPARE(formatter->time(),time);
- QCOMPARE(formatter->dateTime().time(),time);
-
- QCOMPARE(formatter->timeText(),time.toString(Qt::SystemLocaleShortDate));
-
- formatter->setLongStyle(true);
- QCOMPARE(formatter->timeText(),time.toString(Qt::SystemLocaleLongDate));
-
- formatter->setTimeFormat("H:m:s a");
- QCOMPARE(formatter->timeFormat(), QLatin1String("H:m:s a"));
- QCOMPARE(formatter->timeText(),time.toString("H:m:s a"));
-
- formatter->setTimeFormat("hh:mm:ss.zzz");
- QCOMPARE(formatter->timeText(),time.toString("hh:mm:ss.zzz"));
-
- QVERIFY(formatter->dateText().isEmpty());
- QVERIFY(formatter->dateTimeText().isEmpty());
-
- delete formatter;
-}
-
-void tst_qmldatetimeformatter::dateTime()
-{
- QmlEngine engine;
- QmlComponent formatterComponent(&engine);
- formatterComponent.setData("import Qt 4.6\n DateTimeFormatter { dateTime: \"1978-03-04T09:13:54\" }", QUrl::fromLocalFile(""));
- QmlDateTimeFormatter *formatter = qobject_cast<QmlDateTimeFormatter*>(formatterComponent.create());
- if(formatterComponent.isError())
- qDebug() << formatterComponent.errors();
- QVERIFY(formatter != 0);
-
- QDateTime dateTime(QDate(1978,03,04),QTime(9,13,54));
- QCOMPARE(formatter->dateTime(),dateTime);
- QCOMPARE(formatter->date(),dateTime.date());
- QCOMPARE(formatter->time(),dateTime.time());
- QCOMPARE(formatter->dateTimeText(),dateTime.toString(Qt::SystemLocaleShortDate));
-
- formatter->setLongStyle(true);
- QCOMPARE(formatter->dateTimeText(),dateTime.toString(Qt::SystemLocaleLongDate));
-
- formatter->setDateTimeFormat("M/d/yy H:m:s a");
- QCOMPARE(formatter->dateTimeFormat(), QLatin1String("M/d/yy H:m:s a"));
- QCOMPARE(formatter->dateTimeText(),dateTime.toString("M/d/yy H:m:s a"));
-
- delete formatter;
-}
-
-QTEST_MAIN(tst_qmldatetimeformatter)
-
-#include "tst_qmldatetimeformatter.moc"
diff --git a/tests/auto/declarative/qmldebug/qmldebug.pro b/tests/auto/declarative/qmldebug/qmldebug.pro
deleted file mode 100644
index f79829d..0000000
--- a/tests/auto/declarative/qmldebug/qmldebug.pro
+++ /dev/null
@@ -1,7 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += network declarative
-macx:CONFIG -= app_bundle
-
-HEADERS += ../shared/debugutil_p.h
-SOURCES += tst_qmldebug.cpp \
- ../shared/debugutil.cpp
diff --git a/tests/auto/declarative/qmldebug/tst_qmldebug.cpp b/tests/auto/declarative/qmldebug/tst_qmldebug.cpp
deleted file mode 100644
index ba07331..0000000
--- a/tests/auto/declarative/qmldebug/tst_qmldebug.cpp
+++ /dev/null
@@ -1,841 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QSignalSpy>
-#include <QTimer>
-#include <QHostAddress>
-#include <QDebug>
-#include <QThread>
-
-#include <QtDeclarative/qmlengine.h>
-#include <QtDeclarative/qmlcontext.h>
-#include <QtDeclarative/qmlcomponent.h>
-#include <QtDeclarative/qmlexpression.h>
-#include <QtDeclarative/qmlmetatype.h>
-#include <QtDeclarative/qmlmetaproperty.h>
-#include <QtDeclarative/qmlbinding.h>
-
-#include <private/qmldebug_p.h>
-#include <private/qmlenginedebug_p.h>
-#include <private/qmldebugclient_p.h>
-#include <private/qmldebugservice_p.h>
-#include <private/qmlgraphicsrectangle_p.h>
-
-#include "../shared/debugutil_p.h"
-
-Q_DECLARE_METATYPE(QmlDebugWatch::State)
-
-
-class tst_QmlDebug : public QObject
-{
- Q_OBJECT
-
-public:
- tst_QmlDebug(QmlDebugTestData *data)
- {
- m_conn = data->conn;
- m_engine = data->engine;
- m_rootItem = data->items[0];
- }
-
-private:
- QmlDebugObjectReference findRootObject();
- QmlDebugPropertyReference findProperty(const QList<QmlDebugPropertyReference> &props, const QString &name) const;
- void waitForQuery(QmlDebugQuery *query);
-
- void recursiveObjectTest(QObject *o, const QmlDebugObjectReference &oref, bool recursive) const;
-
- void recursiveCompareObjects(const QmlDebugObjectReference &a, const QmlDebugObjectReference &b) const;
- void recursiveCompareContexts(const QmlDebugContextReference &a, const QmlDebugContextReference &b) const;
- void compareProperties(const QmlDebugPropertyReference &a, const QmlDebugPropertyReference &b) const;
-
- QmlDebugConnection *m_conn;
- QmlEngineDebug *m_dbg;
- QmlEngine *m_engine;
- QmlGraphicsItem *m_rootItem;
-
-private slots:
- void initTestCase();
-
- 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_QmlDebugFileReference();
- void tst_QmlDebugEngineReference();
- void tst_QmlDebugObjectReference();
- void tst_QmlDebugContextReference();
- void tst_QmlDebugPropertyReference();
-};
-
-QmlDebugObjectReference tst_QmlDebug::findRootObject()
-{
- QmlDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this);
- waitForQuery(q_engines);
-
- if (q_engines->engines().count() == 0)
- return QmlDebugObjectReference();
- QmlDebugRootContextQuery *q_context = m_dbg->queryRootContexts(q_engines->engines()[0].debugId(), this);
- waitForQuery(q_context);
-
- if (q_context->rootContext().objects().count() == 0)
- return QmlDebugObjectReference();
- QmlDebugObjectQuery *q_obj = m_dbg->queryObject(q_context->rootContext().objects()[0], this);
- waitForQuery(q_obj);
-
- QmlDebugObjectReference result = q_obj->object();
-
- delete q_engines;
- delete q_context;
- delete q_obj;
-
- return result;
-}
-
-QmlDebugPropertyReference tst_QmlDebug::findProperty(const QList<QmlDebugPropertyReference> &props, const QString &name) const
-{
- foreach(const QmlDebugPropertyReference &p, props) {
- if (p.name() == name)
- return p;
- }
- return QmlDebugPropertyReference();
-}
-
-void tst_QmlDebug::waitForQuery(QmlDebugQuery *query)
-{
- QVERIFY(query);
- QCOMPARE(query->parent(), this);
- QVERIFY(query->state() == QmlDebugQuery::Waiting);
- if (!QmlDebugTest::waitForSignal(query, SIGNAL(stateChanged(QmlDebugQuery::State))))
- QFAIL("query timed out");
-}
-
-void tst_QmlDebug::recursiveObjectTest(QObject *o, const QmlDebugObjectReference &oref, bool recursive) const
-{
- const QMetaObject *meta = o->metaObject();
-
- QmlType *type = QmlMetaType::qmlType(o->metaObject());
- QString className = type ? type->qmlTypeName() : QString();
- className = className.mid(className.lastIndexOf(QLatin1Char('/'))+1);
-
- QCOMPARE(oref.debugId(), QmlDebugService::idForObject(o));
- QCOMPARE(oref.name(), o->objectName());
- QCOMPARE(oref.className(), className);
- QCOMPARE(oref.contextDebugId(), QmlDebugService::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 = QmlDebugService::idForObject(child);
- QVERIFY(debugId >= 0);
-
- QmlDebugObjectReference cref;
- foreach (const QmlDebugObjectReference &ref, oref.children()) {
- if (ref.debugId() == debugId) {
- cref = ref;
- break;
- }
- }
- QVERIFY(cref.debugId() >= 0);
-
- if (recursive)
- recursiveObjectTest(child, cref, true);
- }
-
- foreach (const QmlDebugPropertyReference &p, oref.properties()) {
- QCOMPARE(p.objectDebugId(), QmlDebugService::idForObject(o));
-
- // signal properties are fake - they are generated from QmlBoundSignal children
- if (p.name().startsWith("on") && p.name().length() > 2 && p.name()[2].isUpper()) {
- QVERIFY(p.value().toString().startsWith('{') && p.value().toString().endsWith('}'));
- 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) // TODO test complex types
- QCOMPARE(p.value(), pmeta.read(o));
-
- if (p.name() == "parent")
- QVERIFY(p.valueTypeName() == "QGraphicsObject*" || p.valueTypeName() == "QmlGraphicsItem*");
- else
- QCOMPARE(p.valueTypeName(), QString::fromUtf8(pmeta.typeName()));
-
- QmlAbstractBinding *binding = QmlMetaProperty(o, p.name()).binding();
- if (binding)
- QCOMPARE(binding->expression(), p.binding());
-
- QCOMPARE(p.hasNotifySignal(), pmeta.hasNotifySignal());
-
- QVERIFY(pmeta.isValid());
- }
-}
-
-void tst_QmlDebug::recursiveCompareObjects(const QmlDebugObjectReference &a, const QmlDebugObjectReference &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<QmlDebugPropertyReference> aprops = a.properties();
- QList<QmlDebugPropertyReference> 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_QmlDebug::recursiveCompareContexts(const QmlDebugContextReference &a, const QmlDebugContextReference &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_QmlDebug::compareProperties(const QmlDebugPropertyReference &a, const QmlDebugPropertyReference &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_QmlDebug::initTestCase()
-{
- m_dbg = new QmlEngineDebug(m_conn, this);
-
- qRegisterMetaType<QmlDebugWatch::State>();
-}
-
-void tst_QmlDebug::watch_property()
-{
- QmlDebugObjectReference obj = findRootObject();
- QmlDebugPropertyReference prop = findProperty(obj.properties(), "width");
-
- QmlDebugPropertyWatch *watch;
-
- QmlEngineDebug *unconnected = new QmlEngineDebug(0);
- watch = unconnected->addWatch(prop, this);
- QCOMPARE(watch->state(), QmlDebugWatch::Dead);
- delete watch;
- delete unconnected;
-
- watch = m_dbg->addWatch(QmlDebugPropertyReference(), this);
- QVERIFY(QmlDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QmlDebugWatch::State))));
- QCOMPARE(watch->state(), QmlDebugWatch::Inactive);
- delete watch;
-
- watch = m_dbg->addWatch(prop, this);
- QCOMPARE(watch->state(), QmlDebugWatch::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(QmlDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QmlDebugWatch::State))));
- QCOMPARE(watch->state(), QmlDebugWatch::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_QmlDebug::watch_object()
-{
- QmlDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this);
- waitForQuery(q_engines);
-
- Q_ASSERT(q_engines->engines().count() > 0);
- QmlDebugRootContextQuery *q_context = m_dbg->queryRootContexts(q_engines->engines()[0].debugId(), this);
- waitForQuery(q_context);
-
- Q_ASSERT(q_context->rootContext().objects().count() > 0);
- QmlDebugObjectQuery *q_obj = m_dbg->queryObject(q_context->rootContext().objects()[0], this);
- waitForQuery(q_obj);
-
- QmlDebugObjectReference obj = q_obj->object();
-
- delete q_engines;
- delete q_context;
- delete q_obj;
-
- QmlDebugWatch *watch;
-
- QmlEngineDebug *unconnected = new QmlEngineDebug(0);
- watch = unconnected->addWatch(obj, this);
- QCOMPARE(watch->state(), QmlDebugWatch::Dead);
- delete watch;
- delete unconnected;
-
- watch = m_dbg->addWatch(QmlDebugObjectReference(), this);
- QVERIFY(QmlDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QmlDebugWatch::State))));
- QCOMPARE(watch->state(), QmlDebugWatch::Inactive);
- delete watch;
-
- watch = m_dbg->addWatch(obj, this);
- QCOMPARE(watch->state(), QmlDebugWatch::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(QmlDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QmlDebugWatch::State))));
- QCOMPARE(watch->state(), QmlDebugWatch::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_QmlDebug::watch_expression()
-{
- QFETCH(QString, expr);
- QFETCH(int, increment);
- QFETCH(int, incrementCount);
-
- int origWidth = m_rootItem->property("width").toInt();
-
- QmlDebugObjectReference obj = findRootObject();
-
- QmlDebugObjectExpressionWatch *watch;
-
- QmlEngineDebug *unconnected = new QmlEngineDebug(0);
- watch = unconnected->addWatch(obj, expr, this);
- QCOMPARE(watch->state(), QmlDebugWatch::Dead);
- delete watch;
- delete unconnected;
-
- watch = m_dbg->addWatch(QmlDebugObjectReference(), expr, this);
- QVERIFY(QmlDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QmlDebugWatch::State))));
- QCOMPARE(watch->state(), QmlDebugWatch::Inactive);
- delete watch;
-
- watch = m_dbg->addWatch(obj, expr, this);
- QCOMPARE(watch->state(), QmlDebugWatch::Waiting);
- QCOMPARE(watch->objectDebugId(), obj.debugId());
- QCOMPARE(watch->expression(), expr);
-
- QSignalSpy spyState(watch, SIGNAL(stateChanged(QmlDebugWatch::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 (!QmlDebugTest::waitForSignal(watch, SIGNAL(valueChanged(QByteArray,QVariant))))
- QFAIL("Did not receive valueChanged() for expression");
- }
-
- if (spyState.count() == 0)
- QVERIFY(QmlDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QmlDebugWatch::State))));
- QCOMPARE(spyState.count(), 1);
- QCOMPARE(watch->state(), QmlDebugWatch::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_QmlDebug::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_QmlDebug::watch_context()
-{
- QmlDebugContextReference c;
- QTest::ignoreMessage(QtWarningMsg, "QmlEngineDebug::addWatch(): Not implemented");
- QVERIFY(!m_dbg->addWatch(c, QString(), this));
-}
-
-void tst_QmlDebug::watch_file()
-{
- QmlDebugFileReference f;
- QTest::ignoreMessage(QtWarningMsg, "QmlEngineDebug::addWatch(): Not implemented");
- QVERIFY(!m_dbg->addWatch(f, this));
-}
-
-void tst_QmlDebug::queryAvailableEngines()
-{
- QmlDebugEnginesQuery *q_engines;
-
- QmlEngineDebug *unconnected = new QmlEngineDebug(0);
- q_engines = unconnected->queryAvailableEngines(0);
- QCOMPARE(q_engines->state(), QmlDebugQuery::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<QmlDebugEngineReference> engines = q_engines->engines();
- QCOMPARE(engines.count(), 1);
-
- foreach(const QmlDebugEngineReference &e, engines) {
- QCOMPARE(e.debugId(), QmlDebugService::idForObject(m_engine));
- QCOMPARE(e.name(), m_engine->objectName());
- }
-
- delete q_engines;
-}
-
-void tst_QmlDebug::queryRootContexts()
-{
- QmlDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this);
- waitForQuery(q_engines);
- int engineId = q_engines->engines()[0].debugId();
-
- QmlDebugRootContextQuery *q_context;
-
- QmlEngineDebug *unconnected = new QmlEngineDebug(0);
- q_context = unconnected->queryRootContexts(engineId, this);
- QCOMPARE(q_context->state(), QmlDebugQuery::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);
-
- QmlContext *actualContext = m_engine->rootContext();
- QmlDebugContextReference context = q_context->rootContext();
- QCOMPARE(context.debugId(), QmlDebugService::idForObject(actualContext));
- QCOMPARE(context.name(), actualContext->objectName());
-
- QCOMPARE(context.objects().count(), 2); // 2 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(), 1);
- QVERIFY(context.contexts()[0].debugId() >= 0);
- QCOMPARE(context.contexts()[0].name(), QString("tst_QmlDebug_childContext"));
-
- delete q_engines;
- delete q_context;
-}
-
-void tst_QmlDebug::queryObject()
-{
- QFETCH(bool, recursive);
-
- QmlDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this);
- waitForQuery(q_engines);
-
- QmlDebugRootContextQuery *q_context = m_dbg->queryRootContexts(q_engines->engines()[0].debugId(), this);
- waitForQuery(q_context);
- QmlDebugObjectReference rootObject = q_context->rootContext().objects()[0];
-
- QmlDebugObjectQuery *q_obj = 0;
-
- QmlEngineDebug *unconnected = new QmlEngineDebug(0);
- q_obj = recursive ? unconnected->queryObjectRecursive(rootObject, this) : unconnected->queryObject(rootObject, this);
- QCOMPARE(q_obj->state(), QmlDebugQuery::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);
-
- QmlDebugObjectReference obj = q_obj->object();
-
- delete q_engines;
- delete q_context;
- delete q_obj;
-
- // check source as defined in main()
- QmlDebugFileReference source = obj.source();
- QCOMPARE(source.url(), QUrl::fromLocalFile(""));
- QCOMPARE(source.lineNumber(), 2);
- QCOMPARE(source.columnNumber(), 1);
-
- // generically test all properties, children and childrens' properties
- recursiveObjectTest(m_rootItem, obj, recursive);
-
- if (recursive) {
- foreach(const QmlDebugObjectReference &child, obj.children())
- QVERIFY(child.properties().count() > 0);
-
- QmlDebugObjectReference rect;
- QmlDebugObjectReference text;
- foreach (const QmlDebugObjectReference &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 QmlDebugObjectReference &child, obj.children())
- QCOMPARE(child.properties().count(), 0);
- }
-}
-
-void tst_QmlDebug::queryObject_data()
-{
- QTest::addColumn<bool>("recursive");
-
- QTest::newRow("non-recursive") << false;
- QTest::newRow("recursive") << true;
-}
-
-void tst_QmlDebug::queryExpressionResult()
-{
- QFETCH(QString, expr);
- QFETCH(QVariant, result);
-
- QmlDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this);
- waitForQuery(q_engines); // check immediate deletion is ok
-
- QmlDebugRootContextQuery *q_context = m_dbg->queryRootContexts(q_engines->engines()[0].debugId(), this);
- waitForQuery(q_context);
- int objectId = q_context->rootContext().objects()[0].debugId();
-
- QmlDebugExpressionQuery *q_expr;
-
- QmlEngineDebug *unconnected = new QmlEngineDebug(0);
- q_expr = unconnected->queryExpressionResult(objectId, expr, this);
- QCOMPARE(q_expr->state(), QmlDebugQuery::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(), expr);
- waitForQuery(q_expr);
-
- QCOMPARE(q_expr->result(), result);
-
- delete q_engines;
- delete q_context;
- delete q_expr;
-}
-
-void tst_QmlDebug::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>"));
-}
-
-void tst_QmlDebug::tst_QmlDebugFileReference()
-{
- QmlDebugFileReference 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);
-
- QmlDebugFileReference copy(ref);
- QmlDebugFileReference copyAssign;
- copyAssign = ref;
- foreach (const QmlDebugFileReference &r, (QList<QmlDebugFileReference>() << copy << copyAssign)) {
- QCOMPARE(r.url(), ref.url());
- QCOMPARE(r.lineNumber(), ref.lineNumber());
- QCOMPARE(r.columnNumber(), ref.columnNumber());
- }
-}
-
-void tst_QmlDebug::tst_QmlDebugEngineReference()
-{
- QmlDebugEngineReference ref;
- QCOMPARE(ref.debugId(), -1);
- QVERIFY(ref.name().isEmpty());
-
- ref = QmlDebugEngineReference(1);
- QCOMPARE(ref.debugId(), 1);
- QVERIFY(ref.name().isEmpty());
-
- QmlDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this);
- waitForQuery(q_engines);
- ref = q_engines->engines()[0];
- delete q_engines;
-
- QmlDebugEngineReference copy(ref);
- QmlDebugEngineReference copyAssign;
- copyAssign = ref;
- foreach (const QmlDebugEngineReference &r, (QList<QmlDebugEngineReference>() << copy << copyAssign)) {
- QCOMPARE(r.debugId(), ref.debugId());
- QCOMPARE(r.name(), ref.name());
- }
-}
-
-void tst_QmlDebug::tst_QmlDebugObjectReference()
-{
- QmlDebugObjectReference 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());
-
- QmlDebugFileReference source = ref.source();
- QVERIFY(source.url().isEmpty());
- QVERIFY(source.lineNumber() < 0);
- QVERIFY(source.columnNumber() < 0);
-
- ref = QmlDebugObjectReference(1);
- QCOMPARE(ref.debugId(), 1);
-
- QmlDebugObjectReference rootObject = findRootObject();
- QmlDebugObjectQuery *query = m_dbg->queryObjectRecursive(rootObject, this);
- waitForQuery(query);
- ref = query->object();
- delete query;
-
- QVERIFY(ref.debugId() >= 0);
-
- QmlDebugObjectReference copy(ref);
- QmlDebugObjectReference copyAssign;
- copyAssign = ref;
- foreach (const QmlDebugObjectReference &r, (QList<QmlDebugObjectReference>() << copy << copyAssign))
- recursiveCompareObjects(r, ref);
-}
-
-void tst_QmlDebug::tst_QmlDebugContextReference()
-{
- QmlDebugContextReference ref;
- QCOMPARE(ref.debugId(), -1);
- QVERIFY(ref.name().isEmpty());
- QVERIFY(ref.objects().isEmpty());
- QVERIFY(ref.contexts().isEmpty());
-
- QmlDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this);
- waitForQuery(q_engines);
- QmlDebugRootContextQuery *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);
-
- QmlDebugContextReference copy(ref);
- QmlDebugContextReference copyAssign;
- copyAssign = ref;
- foreach (const QmlDebugContextReference &r, (QList<QmlDebugContextReference>() << copy << copyAssign))
- recursiveCompareContexts(r, ref);
-}
-
-void tst_QmlDebug::tst_QmlDebugPropertyReference()
-{
- QmlDebugObjectReference rootObject = findRootObject();
- QmlDebugObjectQuery *query = m_dbg->queryObject(rootObject, this);
- waitForQuery(query);
- QmlDebugObjectReference obj = query->object();
- delete query;
-
- QmlDebugPropertyReference 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());
-
- QmlDebugPropertyReference copy(ref);
- QmlDebugPropertyReference copyAssign;
- copyAssign = ref;
- foreach (const QmlDebugPropertyReference &r, (QList<QmlDebugPropertyReference>() << copy << copyAssign))
- compareProperties(r, ref);
-}
-
-
-class tst_QmlDebug_Factory : public QmlTestFactory
-{
-public:
- QObject *createTest(QmlDebugTestData *data)
- {
- tst_QmlDebug *test = new tst_QmlDebug(data);
- QmlContext *c = new QmlContext(data->engine->rootContext(), test);
- c->setObjectName("tst_QmlDebug_childContext");
- return test;
- }
-};
-
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
-
- QList<QByteArray> qml;
- qml << "import Qt 4.6\n"
- "Item {"
- "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') }"
- "}"
- "}";
- // add second component to test multiple root contexts
- qml << "import Qt 4.6\n"
- "Item {}";
- tst_QmlDebug_Factory factory;
- return QmlDebugTest::runTests(&factory, qml);
-}
-
-//QTEST_MAIN(tst_QmlDebug)
-
-#include "tst_qmldebug.moc"
diff --git a/tests/auto/declarative/qmldebugclient/qmldebugclient.pro b/tests/auto/declarative/qmldebugclient/qmldebugclient.pro
deleted file mode 100644
index 36aa818..0000000
--- a/tests/auto/declarative/qmldebugclient/qmldebugclient.pro
+++ /dev/null
@@ -1,7 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += network declarative
-macx:CONFIG -= app_bundle
-
-HEADERS += ../shared/debugutil_p.h
-SOURCES += tst_qmldebugclient.cpp \
- ../shared/debugutil.cpp
diff --git a/tests/auto/declarative/qmldebugclient/tst_qmldebugclient.cpp b/tests/auto/declarative/qmldebugclient/tst_qmldebugclient.cpp
deleted file mode 100644
index 3c87d71..0000000
--- a/tests/auto/declarative/qmldebugclient/tst_qmldebugclient.cpp
+++ /dev/null
@@ -1,157 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QSignalSpy>
-#include <QTimer>
-#include <QHostAddress>
-#include <QDebug>
-#include <QThread>
-
-#include <QtDeclarative/qmlengine.h>
-
-#include <private/qmldebug_p.h>
-#include <private/qmlenginedebug_p.h>
-#include <private/qmldebugclient_p.h>
-#include <private/qmldebugservice_p.h>
-
-#include "../shared/debugutil_p.h"
-
-class tst_QmlDebugClient : public QObject
-{
- Q_OBJECT
-
-public:
- tst_QmlDebugClient(QmlDebugTestData *data)
- {
- m_conn = data->conn;
- }
-
- QmlDebugConnection *m_conn;
-
-private slots:
- void name();
- void isEnabled();
- void setEnabled();
- void isConnected();
- void sendMessage();
-};
-
-void tst_QmlDebugClient::name()
-{
- QString name = "tst_QmlDebugClient::name()";
-
- QmlDebugClient client(name, m_conn);
- QCOMPARE(client.name(), name);
-}
-
-void tst_QmlDebugClient::isEnabled()
-{
- QmlDebugClient client("tst_QmlDebugClient::isEnabled()", m_conn);
- QCOMPARE(client.isEnabled(), false);
-}
-
-void tst_QmlDebugClient::setEnabled()
-{
- QmlDebugTestService service("tst_QmlDebugClient::setEnabled()");
- QmlDebugTestClient client("tst_QmlDebugClient::setEnabled()", m_conn);
-
- QCOMPARE(service.isEnabled(), false);
-
- client.setEnabled(true);
- QCOMPARE(client.isEnabled(), true);
- QmlDebugTest::waitForSignal(&service, SIGNAL(enabledStateChanged()));
- QCOMPARE(service.isEnabled(), true);
-
- client.setEnabled(false);
- QCOMPARE(client.isEnabled(), false);
- QmlDebugTest::waitForSignal(&service, SIGNAL(enabledStateChanged()));
- QCOMPARE(service.isEnabled(), false);
-}
-
-void tst_QmlDebugClient::isConnected()
-{
- QmlDebugClient client1("tst_QmlDebugClient::isConnected() A", m_conn);
- QCOMPARE(client1.isConnected(), true);
-
- QmlDebugConnection conn;
- QmlDebugClient client2("tst_QmlDebugClient::isConnected() B", &conn);
- QCOMPARE(client2.isConnected(), false);
-
- QmlDebugClient client3("tst_QmlDebugClient::isConnected() C", 0);
- QCOMPARE(client3.isConnected(), false);
-
- // duplicate plugin name
- QTest::ignoreMessage(QtWarningMsg, "QmlDebugClient: Conflicting plugin name \"tst_QmlDebugClient::isConnected() A\" ");
- QmlDebugClient client4("tst_QmlDebugClient::isConnected() A", m_conn);
- QCOMPARE(client4.isConnected(), false);
-}
-
-void tst_QmlDebugClient::sendMessage()
-{
- QmlDebugTestService service("tst_QmlDebugClient::sendMessage()");
- QmlDebugTestClient client("tst_QmlDebugClient::sendMessage()", m_conn);
-
- QByteArray msg = "hello!";
-
- client.sendMessage(msg);
- QByteArray resp = client.waitForResponse();
- QCOMPARE(resp, msg);
-}
-
-
-class tst_QmlDebugClient_Factory : public QmlTestFactory
-{
-public:
- QObject *createTest(QmlDebugTestData *data) { return new tst_QmlDebugClient(data); }
-};
-
-
-// This does not use QTEST_MAIN because the test has to be created and run
-// in a separate thread.
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
-
- tst_QmlDebugClient_Factory factory;
- return QmlDebugTest::runTests(&factory);
-}
-
-#include "tst_qmldebugclient.moc"
diff --git a/tests/auto/declarative/qmldebugservice/qmldebugservice.pro b/tests/auto/declarative/qmldebugservice/qmldebugservice.pro
deleted file mode 100644
index 9995f1f..0000000
--- a/tests/auto/declarative/qmldebugservice/qmldebugservice.pro
+++ /dev/null
@@ -1,7 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += network declarative
-macx:CONFIG -= app_bundle
-
-HEADERS += ../shared/debugutil_p.h
-SOURCES += tst_qmldebugservice.cpp \
- ../shared/debugutil.cpp
diff --git a/tests/auto/declarative/qmldebugservice/tst_qmldebugservice.cpp b/tests/auto/declarative/qmldebugservice/tst_qmldebugservice.cpp
deleted file mode 100644
index e9e31ca..0000000
--- a/tests/auto/declarative/qmldebugservice/tst_qmldebugservice.cpp
+++ /dev/null
@@ -1,190 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QSignalSpy>
-#include <QTimer>
-#include <QHostAddress>
-#include <QDebug>
-#include <QThread>
-
-#include <QtDeclarative/qmlengine.h>
-
-#include <private/qmldebug_p.h>
-#include <private/qmlenginedebug_p.h>
-#include <private/qmldebugclient_p.h>
-#include <private/qmldebugservice_p.h>
-
-#include "../shared/debugutil_p.h"
-
-class tst_QmlDebugService : public QObject
-{
- Q_OBJECT
-
-public:
- tst_QmlDebugService(QmlDebugTestData *data)
- {
- m_conn = data->conn;
- }
-
- QmlDebugConnection *m_conn;
-
-private slots:
- void name();
- void isEnabled();
- void enabledChanged();
- void sendMessage();
- void idForObject();
- void objectForId();
- void objectToString();
-};
-
-void tst_QmlDebugService::name()
-{
- QString name = "tst_QmlDebugService::name()";
-
- QmlDebugService service(name);
- QCOMPARE(service.name(), name);
-}
-
-void tst_QmlDebugService::isEnabled()
-{
- QmlDebugTestService service("tst_QmlDebugService::isEnabled()", m_conn);
- QCOMPARE(service.isEnabled(), false);
-
- QmlDebugTestClient client("tst_QmlDebugService::isEnabled()", m_conn);
- client.setEnabled(true);
- QmlDebugTest::waitForSignal(&service, SIGNAL(enabledStateChanged()));
- QCOMPARE(service.isEnabled(), true);
-
- QTest::ignoreMessage(QtWarningMsg, "QmlDebugService: Conflicting plugin name \"tst_QmlDebugService::isEnabled()\" ");
- QmlDebugService duplicate("tst_QmlDebugService::isEnabled()", m_conn);
- QCOMPARE(duplicate.isEnabled(), false);
-}
-
-void tst_QmlDebugService::enabledChanged()
-{
- QmlDebugTestService service("tst_QmlDebugService::enabledChanged()");
- QmlDebugTestClient client("tst_QmlDebugService::enabledChanged()", m_conn);
-
- QCOMPARE(service.enabled, false);
-
- client.setEnabled(true);
- QmlDebugTest::waitForSignal(&service, SIGNAL(enabledStateChanged()));
- QCOMPARE(service.enabled, true);
-}
-
-void tst_QmlDebugService::sendMessage()
-{
- QmlDebugTestService service("tst_QmlDebugService::sendMessage()");
- QmlDebugTestClient client("tst_QmlDebugService::sendMessage()", m_conn);
-
- QByteArray msg = "hello!";
-
- client.sendMessage(msg);
- QByteArray resp = client.waitForResponse();
- QCOMPARE(resp, msg);
-}
-
-void tst_QmlDebugService::idForObject()
-{
- QCOMPARE(QmlDebugService::idForObject(0), -1);
-
- QObject *objA = new QObject;
-
- int idA = QmlDebugService::idForObject(objA);
- QVERIFY(idA >= 0);
- QCOMPARE(QmlDebugService::objectForId(idA), objA);
-
- int idAA = QmlDebugService::idForObject(objA);
- QCOMPARE(idAA, idA);
-
- QObject *objB = new QObject;
- int idB = QmlDebugService::idForObject(objB);
- QVERIFY(idB != idA);
- QCOMPARE(QmlDebugService::objectForId(idB), objB);
-
- delete objA;
- delete objB;
-}
-
-void tst_QmlDebugService::objectForId()
-{
- QCOMPARE(QmlDebugService::objectForId(-1), static_cast<QObject*>(0));
- QCOMPARE(QmlDebugService::objectForId(1), static_cast<QObject*>(0));
-
- QObject *obj = new QObject;
- int id = QmlDebugService::idForObject(obj);
- QCOMPARE(QmlDebugService::objectForId(id), obj);
-
- delete obj;
- QCOMPARE(QmlDebugService::objectForId(id), static_cast<QObject*>(0));
-}
-
-void tst_QmlDebugService::objectToString()
-{
- QCOMPARE(QmlDebugService::objectToString(0), QString("NULL"));
-
- QObject *obj = new QObject;
- QCOMPARE(QmlDebugService::objectToString(obj), QString("QObject: <unnamed>"));
-
- obj->setObjectName("Hello");
- QCOMPARE(QmlDebugService::objectToString(obj), QString("QObject: Hello"));
- delete obj;
-}
-
-
-class tst_QmlDebugService_Factory : public QmlTestFactory
-{
-public:
- QObject *createTest(QmlDebugTestData *data) { return new tst_QmlDebugService(data); }
-};
-
-// This does not use QTEST_MAIN because the test has to be created and run
-// in a separate thread.
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
-
- tst_QmlDebugService_Factory factory;
- return QmlDebugTest::runTests(&factory);
-}
-
-#include "tst_qmldebugservice.moc"
diff --git a/tests/auto/declarative/qmldom/qmldom.pro b/tests/auto/declarative/qmldom/qmldom.pro
deleted file mode 100644
index 7ff317d..0000000
--- a/tests/auto/declarative/qmldom/qmldom.pro
+++ /dev/null
@@ -1,7 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qmldom.cpp
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmldom/tst_qmldom.cpp b/tests/auto/declarative/qmldom/tst_qmldom.cpp
deleted file mode 100644
index 16cdef0..0000000
--- a/tests/auto/declarative/qmldom/tst_qmldom.cpp
+++ /dev/null
@@ -1,1313 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtDeclarative/qmlengine.h>
-#include <QtDeclarative/qmlcomponent.h>
-#include <QtDeclarative/private/qmldom_p.h>
-
-#include <QtCore/QDebug>
-#include <QtCore/QFile>
-
-class tst_qmldom : public QObject
-{
- Q_OBJECT
-public:
- tst_qmldom() {}
-
-private slots:
- void loadSimple();
- void loadProperties();
- void loadGroupedProperties();
- void loadChildObject();
- void loadComposite();
- void loadImports();
- void loadErrors();
- void loadSyntaxErrors();
- void loadRemoteErrors();
- void loadDynamicProperty();
- void loadComponent();
-
- void testValueSource();
- void testValueInterceptor();
-
- void object_dynamicProperty();
- void object_property();
- void object_url();
-
- void copy();
- void position();
-private:
- QmlEngine engine;
-};
-
-
-void tst_qmldom::loadSimple()
-{
- QByteArray qml = "import Qt 4.6\n"
- "Item {}";
-
- QmlDomDocument document;
- QVERIFY(document.load(&engine, qml));
- QVERIFY(document.errors().isEmpty());
-
- QmlDomObject rootObject = document.rootObject();
- QVERIFY(rootObject.isValid());
- QVERIFY(!rootObject.isComponent());
- QVERIFY(!rootObject.isCustomType());
- QVERIFY(rootObject.objectType() == "Qt/Item");
- QVERIFY(rootObject.objectTypeMajorVersion() == 4);
- QVERIFY(rootObject.objectTypeMinorVersion() == 6);
-}
-
-// Test regular properties
-void tst_qmldom::loadProperties()
-{
- QByteArray qml = "import Qt 4.6\n"
- "Item { id : item; x : 300; visible : true }";
-
- QmlDomDocument document;
- QVERIFY(document.load(&engine, qml));
-
- QmlDomObject rootObject = document.rootObject();
- QVERIFY(rootObject.isValid());
- QVERIFY(rootObject.objectId() == "item");
- QCOMPARE(rootObject.properties().size(), 3);
-
- QmlDomProperty xProperty = rootObject.property("x");
- QVERIFY(xProperty.propertyName() == "x");
- QCOMPARE(xProperty.propertyNameParts().count(), 1);
- QVERIFY(xProperty.propertyNameParts().at(0) == "x");
- QCOMPARE(xProperty.position(), 32);
- QCOMPARE(xProperty.length(), 1);
- QVERIFY(xProperty.value().isLiteral());
- QVERIFY(xProperty.value().toLiteral().literal() == "300");
-
- QmlDomProperty visibleProperty = rootObject.property("visible");
- QVERIFY(visibleProperty.propertyName() == "visible");
- QCOMPARE(visibleProperty.propertyNameParts().count(), 1);
- QVERIFY(visibleProperty.propertyNameParts().at(0) == "visible");
- QCOMPARE(visibleProperty.position(), 41);
- QCOMPARE(visibleProperty.length(), 7);
- QVERIFY(visibleProperty.value().isLiteral());
- QVERIFY(visibleProperty.value().toLiteral().literal() == "true");
-}
-
-// Test grouped properties
-void tst_qmldom::loadGroupedProperties()
-{
- {
- QByteArray qml = "import Qt 4.6\n"
- "Item { anchors.left: parent.left; anchors.right: parent.right }";
-
- QmlDomDocument document;
- QVERIFY(document.load(&engine, qml));
-
- QmlDomObject rootItem = document.rootObject();
- QVERIFY(rootItem.isValid());
- QVERIFY(rootItem.properties().size() == 2);
-
- // Order is not deterministic
- QmlDomProperty p0 = rootItem.properties().at(0);
- QmlDomProperty p1 = rootItem.properties().at(1);
- QmlDomProperty leftProperty;
- QmlDomProperty rightProperty;
- if (p0.propertyName() == "anchors.left") {
- leftProperty = p0;
- rightProperty = p1;
- } else {
- leftProperty = p1;
- rightProperty = p0;
- }
-
- QVERIFY(leftProperty.propertyName() == "anchors.left");
- QCOMPARE(leftProperty.propertyNameParts().count(), 2);
- QVERIFY(leftProperty.propertyNameParts().at(0) == "anchors");
- QVERIFY(leftProperty.propertyNameParts().at(1) == "left");
- QCOMPARE(leftProperty.position(), 21);
- QCOMPARE(leftProperty.length(), 12);
- QVERIFY(leftProperty.value().isBinding());
- QVERIFY(leftProperty.value().toBinding().binding() == "parent.left");
-
- QVERIFY(rightProperty.propertyName() == "anchors.right");
- QCOMPARE(rightProperty.propertyNameParts().count(), 2);
- QVERIFY(rightProperty.propertyNameParts().at(0) == "anchors");
- QVERIFY(rightProperty.propertyNameParts().at(1) == "right");
- QCOMPARE(rightProperty.position(), 48);
- QCOMPARE(rightProperty.length(), 13);
- QVERIFY(rightProperty.value().isBinding());
- QVERIFY(rightProperty.value().toBinding().binding() == "parent.right");
- }
-
- {
- QByteArray qml = "import Qt 4.6\n"
- "Item { \n"
- " anchors {\n"
- " left: parent.left\n"
- " right: parent.right\n"
- " }\n"
- "}";
-
- QmlDomDocument document;
- QVERIFY(document.load(&engine, qml));
-
- QmlDomObject rootItem = document.rootObject();
- QVERIFY(rootItem.isValid());
- QVERIFY(rootItem.properties().size() == 2);
-
- // Order is not deterministic
- QmlDomProperty p0 = rootItem.properties().at(0);
- QmlDomProperty p1 = rootItem.properties().at(1);
- QmlDomProperty leftProperty;
- QmlDomProperty rightProperty;
- if (p0.propertyName() == "anchors.left") {
- leftProperty = p0;
- rightProperty = p1;
- } else {
- leftProperty = p1;
- rightProperty = p0;
- }
-
- QVERIFY(leftProperty.propertyName() == "anchors.left");
- QCOMPARE(leftProperty.propertyNameParts().count(), 2);
- QVERIFY(leftProperty.propertyNameParts().at(0) == "anchors");
- QVERIFY(leftProperty.propertyNameParts().at(1) == "left");
- QCOMPARE(leftProperty.position(), 44);
- QCOMPARE(leftProperty.length(), 4);
- QVERIFY(leftProperty.value().isBinding());
- QVERIFY(leftProperty.value().toBinding().binding() == "parent.left");
-
- QVERIFY(rightProperty.propertyName() == "anchors.right");
- QCOMPARE(rightProperty.propertyNameParts().count(), 2);
- QVERIFY(rightProperty.propertyNameParts().at(0) == "anchors");
- QVERIFY(rightProperty.propertyNameParts().at(1) == "right");
- QCOMPARE(rightProperty.position(), 70);
- QCOMPARE(rightProperty.length(), 5);
- QVERIFY(rightProperty.value().isBinding());
- QVERIFY(rightProperty.value().toBinding().binding() == "parent.right");
- }
-
-}
-
-void tst_qmldom::loadChildObject()
-{
- QByteArray qml = "import Qt 4.6\n"
- "Item { Item {} }";
-
- QmlDomDocument document;
- QVERIFY(document.load(&engine, qml));
-
- QmlDomObject rootItem = document.rootObject();
- QVERIFY(rootItem.isValid());
- QVERIFY(rootItem.properties().size() == 1);
-
- QmlDomProperty listProperty = rootItem.properties().at(0);
- QVERIFY(listProperty.isDefaultProperty());
- QVERIFY(listProperty.value().isList());
-
- QmlDomList list = listProperty.value().toList();
- QVERIFY(list.values().size() == 1);
-
- QmlDomObject childItem = list.values().first().toObject();
- QVERIFY(childItem.isValid());
- QVERIFY(childItem.objectType() == "Qt/Item");
-}
-
-void tst_qmldom::loadComposite()
-{
- QFile file(SRCDIR "/data/top.qml");
- QVERIFY(file.open(QIODevice::ReadOnly | QIODevice::Text));
-
- QmlDomDocument document;
- QVERIFY(document.load(&engine, file.readAll(), QUrl::fromLocalFile(file.fileName())));
- QVERIFY(document.errors().isEmpty());
-
- QmlDomObject rootItem = document.rootObject();
- QVERIFY(rootItem.isValid());
- QCOMPARE(rootItem.objectType(), QByteArray("MyComponent"));
- QCOMPARE(rootItem.properties().size(), 2);
-
- QmlDomProperty widthProperty = rootItem.property("width");
- QVERIFY(widthProperty.value().isLiteral());
-
- QmlDomProperty heightProperty = rootItem.property("height");
- QVERIFY(heightProperty.value().isLiteral());
-}
-
-void tst_qmldom::testValueSource()
-{
- QByteArray qml = "import Qt 4.6\n"
- "Rectangle { height: SpringFollow { spring: 1.4; damping: .15; source: Math.min(Math.max(-130, value*2.2 - 130), 133); }}";
-
- QmlEngine freshEngine;
- QmlDomDocument document;
- QVERIFY(document.load(&freshEngine, qml));
-
- QmlDomObject rootItem = document.rootObject();
- QVERIFY(rootItem.isValid());
- QmlDomProperty heightProperty = rootItem.properties().at(0);
- QVERIFY(heightProperty.propertyName() == "height");
- QVERIFY(heightProperty.value().isValueSource());
-
- const QmlDomValueValueSource valueSource = heightProperty.value().toValueSource();
- QmlDomObject valueSourceObject = valueSource.object();
- QVERIFY(valueSourceObject.isValid());
-
- QVERIFY(valueSourceObject.objectType() == "Qt/SpringFollow");
-
- const QmlDomValue springValue = valueSourceObject.property("spring").value();
- QVERIFY(!springValue.isInvalid());
- QVERIFY(springValue.isLiteral());
- QVERIFY(springValue.toLiteral().literal() == "1.4");
-
- const QmlDomValue sourceValue = valueSourceObject.property("source").value();
- QVERIFY(!sourceValue.isInvalid());
- QVERIFY(sourceValue.isBinding());
- QVERIFY(sourceValue.toBinding().binding() == "Math.min(Math.max(-130, value*2.2 - 130), 133)");
-}
-
-void tst_qmldom::testValueInterceptor()
-{
- QByteArray qml = "import Qt 4.6\n"
- "Rectangle { height: Behavior { NumberAnimation { duration: 100 } } }";
-
- QmlEngine freshEngine;
- QmlDomDocument document;
- QVERIFY(document.load(&freshEngine, qml));
-
- QmlDomObject rootItem = document.rootObject();
- QVERIFY(rootItem.isValid());
- QmlDomProperty heightProperty = rootItem.properties().at(0);
- QVERIFY(heightProperty.propertyName() == "height");
- QVERIFY(heightProperty.value().isValueInterceptor());
-
- const QmlDomValueValueInterceptor valueInterceptor = heightProperty.value().toValueInterceptor();
- QmlDomObject valueInterceptorObject = valueInterceptor.object();
- QVERIFY(valueInterceptorObject.isValid());
-
- QVERIFY(valueInterceptorObject.objectType() == "Qt/Behavior");
-
- const QmlDomValue animationValue = valueInterceptorObject.property("animation").value();
- QVERIFY(!animationValue.isInvalid());
- QVERIFY(animationValue.isObject());
-}
-
-// Test QmlDomDocument::imports()
-void tst_qmldom::loadImports()
-{
- QByteArray qml = "import Qt 4.6\n"
- "import importlib.sublib 4.7\n"
- "import importlib.sublib 4.6 as NewFoo\n"
- "import 'import'\n"
- "import 'import' as X\n"
- "Item {}";
-
- QmlEngine engine;
- engine.addImportPath(SRCDIR "/data");
- QmlDomDocument document;
- QVERIFY(document.load(&engine, qml));
-
- QCOMPARE(document.imports().size(), 5);
-
- QmlDomImport import = document.imports().at(0);
- QCOMPARE(import.type(), QmlDomImport::Library);
- QCOMPARE(import.uri(), QLatin1String("Qt"));
- QCOMPARE(import.qualifier(), QString());
- QCOMPARE(import.version(), QLatin1String("4.6"));
-
- import = document.imports().at(1);
- QCOMPARE(import.type(), QmlDomImport::Library);
- QCOMPARE(import.uri(), QLatin1String("importlib.sublib"));
- QCOMPARE(import.qualifier(), QString());
- QCOMPARE(import.version(), QLatin1String("4.7"));
-
- import = document.imports().at(2);
- QCOMPARE(import.type(), QmlDomImport::Library);
- QCOMPARE(import.uri(), QLatin1String("importlib.sublib"));
- QCOMPARE(import.qualifier(), QLatin1String("NewFoo"));
- QCOMPARE(import.version(), QLatin1String("4.6"));
-
- import = document.imports().at(3);
- QCOMPARE(import.type(), QmlDomImport::File);
- QCOMPARE(import.uri(), QLatin1String("import"));
- QCOMPARE(import.qualifier(), QLatin1String(""));
- QCOMPARE(import.version(), QLatin1String(""));
-
- import = document.imports().at(4);
- QCOMPARE(import.type(), QmlDomImport::File);
- QCOMPARE(import.uri(), QLatin1String("import"));
- QCOMPARE(import.qualifier(), QLatin1String("X"));
- QCOMPARE(import.version(), QLatin1String(""));
-}
-
-// Test loading a file with errors
-void tst_qmldom::loadErrors()
-{
- QByteArray qml = "import Qt 4.6\n"
- "Item {\n"
- " foo: 12\n"
- "}";
-
- QmlDomDocument document;
- QVERIFY(false == document.load(&engine, qml));
-
- QCOMPARE(document.errors().count(), 1);
- QmlError error = document.errors().first();
-
- QCOMPARE(error.url(), QUrl());
- QCOMPARE(error.line(), 3);
- QCOMPARE(error.column(), 3);
- QCOMPARE(error.description(), QString("Cannot assign to non-existent property \"foo\""));
-}
-
-// Test loading a file with syntax errors
-void tst_qmldom::loadSyntaxErrors()
-{
- QByteArray qml = "import Qt 4.6\n"
- "asdf";
-
- QmlDomDocument document;
- QVERIFY(false == document.load(&engine, qml));
-
- QCOMPARE(document.errors().count(), 1);
- QmlError error = document.errors().first();
-
- QCOMPARE(error.url(), QUrl());
- QCOMPARE(error.line(), 2);
- QCOMPARE(error.column(), 1);
- QCOMPARE(error.description(), QString("Syntax error"));
-}
-
-// Test attempting to load a file with remote references
-void tst_qmldom::loadRemoteErrors()
-{
- QByteArray qml = "import Qt 4.6\n"
- "Item {\n"
- " Script {\n"
- " source: \"http://localhost/exampleQmlScript.js\""
- " }\n"
- "}";
- QmlDomDocument document;
- QVERIFY(false == document.load(&engine, qml));
-
- QCOMPARE(document.errors().count(), 1);
- QmlError error = document.errors().first();
-
- QCOMPARE(error.url(), QUrl());
- QCOMPARE(error.line(), -1);
- QCOMPARE(error.column(), -1);
- QCOMPARE(error.description(), QString("QmlDomDocument supports local types only"));
-}
-
-// Test dynamic property declarations
-void tst_qmldom::loadDynamicProperty()
-{
- {
- QByteArray qml = "import Qt 4.6\n"
- "Item {\n"
- " property int a\n"
- " property bool b\n"
- " property double c\n"
- " property real d\n"
- " property string e\n"
- " property url f\n"
- " property color g\n"
- " property date h\n"
- " property var i\n"
- " property variant j\n"
- " property QtObject k\n"
- "}";
-
- QmlDomDocument document;
- QVERIFY(document.load(&engine, qml));
-
- QmlDomObject rootObject = document.rootObject();
- QVERIFY(rootObject.isValid());
-
- QCOMPARE(rootObject.dynamicProperties().count(), 11);
-
-#define DP_TEST(index, name, type, test_position, test_length, propTypeName) \
- { \
- QmlDomDynamicProperty d = rootObject.dynamicProperties().at(index); \
- QVERIFY(d.isValid()); \
- QVERIFY(d.propertyName() == # name ); \
- QVERIFY(d.propertyType() == type); \
- QVERIFY(d.propertyTypeName() == propTypeName); \
- QVERIFY(d.isDefaultProperty() == false); \
- QVERIFY(d.defaultValue().isValid() == false); \
- QCOMPARE(d.position(), test_position); \
- QCOMPARE(d.length(), test_length); \
- } \
-
- DP_TEST(0, a, QVariant::Int, 25, 14, "int");
- DP_TEST(1, b, QVariant::Bool, 44, 15, "bool");
- DP_TEST(2, c, QVariant::Double, 64, 17, "double");
- DP_TEST(3, d, QMetaType::QReal, 86, 15, "real");
- DP_TEST(4, e, QVariant::String, 106, 17, "string");
- DP_TEST(5, f, QVariant::Url, 128, 14, "url");
- DP_TEST(6, g, QVariant::Color, 147, 16, "color");
- DP_TEST(7, h, QVariant::Date, 168, 15, "date");
- DP_TEST(8, i, qMetaTypeId<QVariant>(), 188, 14, "var");
- DP_TEST(9, j, qMetaTypeId<QVariant>(), 207, 18, "variant");
- DP_TEST(10, k, -1, 230, 19, "QtObject");
- }
-
- {
- QByteArray qml = "import Qt 4.6\n"
- "Item {\n"
- " property int a: 12\n"
- " property int b: a + 6\n"
- " default property QtObject c\n"
- "}\n";
-
- QmlDomDocument document;
- QVERIFY(document.load(&engine, qml));
-
- QmlDomObject rootObject = document.rootObject();
- QVERIFY(rootObject.isValid());
-
- QCOMPARE(rootObject.dynamicProperties().count(), 3);
-
- {
- QmlDomDynamicProperty d = rootObject.dynamicProperties().at(0);
- QVERIFY(d.isDefaultProperty() == false);
- QVERIFY(d.defaultValue().isValid());
- QVERIFY(d.defaultValue().propertyName() == "a");
- QVERIFY(d.defaultValue().value().isLiteral());
- }
-
- {
- QmlDomDynamicProperty d = rootObject.dynamicProperties().at(1);
- QVERIFY(d.isDefaultProperty() == false);
- QVERIFY(d.defaultValue().isValid());
- QVERIFY(d.defaultValue().propertyName() == "b");
- QVERIFY(d.defaultValue().value().isBinding());
- }
-
- {
- QmlDomDynamicProperty d = rootObject.dynamicProperties().at(2);
- QVERIFY(d.isDefaultProperty() == true);
- QVERIFY(d.defaultValue().isValid() == false);
- }
- }
-}
-
-// Test inline components
-void tst_qmldom::loadComponent()
-{
- // Explicit component
- {
- QByteArray qml = "import Qt 4.6\n"
- "Item {\n"
- " Component {\n"
- " id: myComponent\n"
- " Item {}\n"
- " }\n"
- "}";
-
- QmlDomDocument document;
- QVERIFY(document.load(&engine, qml));
-
- QmlDomObject rootItem = document.rootObject();
- QVERIFY(rootItem.isValid());
- QVERIFY(rootItem.properties().size() == 1);
-
- QmlDomProperty listProperty = rootItem.properties().at(0);
- QVERIFY(listProperty.isDefaultProperty());
- QVERIFY(listProperty.value().isList());
-
- QmlDomList list = listProperty.value().toList();
- QVERIFY(list.values().size() == 1);
-
- QmlDomObject componentObject = list.values().first().toObject();
- QVERIFY(componentObject.isValid());
- QVERIFY(componentObject.objectClassName() == "Component");
- QVERIFY(componentObject.isComponent());
-
- QmlDomComponent component = componentObject.toComponent();
- QVERIFY(component.isValid());
- QVERIFY(component.objectType() == "Qt/Component");
- QVERIFY(component.objectTypeMajorVersion() == 4);
- QVERIFY(component.objectTypeMinorVersion() == 6);
- QVERIFY(component.objectClassName() == "Component");
- QVERIFY(component.objectId() == "myComponent");
- QVERIFY(component.properties().isEmpty());
- QVERIFY(component.dynamicProperties().isEmpty());
- QVERIFY(component.isCustomType() == false);
- QVERIFY(component.customTypeData() == "");
- QVERIFY(component.isComponent());
- QCOMPARE(component.position(), 25);
- QCOMPARE(component.length(), 57);
-
- QVERIFY(component.componentRoot().isValid());
- QVERIFY(component.componentRoot().objectClassName() == "Item");
- }
-
- // Implicit component
- {
- QByteArray qml = "import Qt 4.6\n"
- "ListView {\n"
- " delegate: Item {}\n"
- "}";
-
- QmlDomDocument document;
- QVERIFY(document.load(&engine, qml));
-
- QmlDomObject rootItem = document.rootObject();
- QVERIFY(rootItem.isValid());
- QVERIFY(rootItem.properties().size() == 1);
-
- QmlDomProperty delegate = rootItem.property("delegate");
-
- QmlDomObject componentObject = delegate.value().toObject();
- QVERIFY(componentObject.isValid());
- QVERIFY(componentObject.objectClassName() == "Component");
- QVERIFY(componentObject.isComponent());
-
- QmlDomComponent component = componentObject.toComponent();
- QVERIFY(component.isValid());
- QVERIFY(component.objectType() == "Qt/Component");
- QVERIFY(component.objectClassName() == "Component");
- QVERIFY(component.objectId() == "");
- QVERIFY(component.properties().isEmpty());
- QVERIFY(component.dynamicProperties().isEmpty());
- QVERIFY(component.isCustomType() == false);
- QVERIFY(component.customTypeData() == "");
- QVERIFY(component.isComponent());
- QCOMPARE(component.position(), 39);
- QCOMPARE(component.length(), 7);
-
- QVERIFY(component.componentRoot().isValid());
- QVERIFY(component.componentRoot().objectClassName() == "Item");
- }
-}
-
-// Test QmlDomObject::dynamicProperty() method
-void tst_qmldom::object_dynamicProperty()
-{
- // Invalid object
- {
- QmlDomObject object;
- QVERIFY(object.dynamicProperty("").isValid() == false);
- QVERIFY(object.dynamicProperty("foo").isValid() == false);
- }
-
-
- // Valid object, no dynamic properties
- {
- QByteArray qml = "import Qt 4.6\n"
- "Item {}";
-
- QmlDomDocument document;
- QVERIFY(document.load(&engine, qml));
-
- QmlDomObject rootObject = document.rootObject();
- QVERIFY(rootObject.isValid());
-
- QVERIFY(rootObject.dynamicProperty("").isValid() == false);
- QVERIFY(rootObject.dynamicProperty("foo").isValid() == false);
- }
-
- // Valid object, dynamic properties
- {
- QByteArray qml = "import Qt 4.6\n"
- "Item {\n"
- " property int a\n"
- "}";
-
- QmlDomDocument document;
- QVERIFY(document.load(&engine, qml));
-
- QmlDomObject rootObject = document.rootObject();
- QVERIFY(rootObject.isValid());
-
- QVERIFY(rootObject.dynamicProperty("").isValid() == false);
- QVERIFY(rootObject.dynamicProperty("foo").isValid() == false);
-
- QmlDomDynamicProperty p = rootObject.dynamicProperty("a");
- QVERIFY(p.isValid());
- QVERIFY(p.propertyName() == "a");
- QVERIFY(p.propertyType() == QVariant::Int);
- QVERIFY(p.propertyTypeName() == "int");
- QVERIFY(p.isDefaultProperty() == false);
- QCOMPARE(p.position(), 25);
- QCOMPARE(p.length(), 14);
- }
-
-}
-
-// Test QmlObject::property() method
-void tst_qmldom::object_property()
-{
- // Invalid object
- {
- QmlDomObject object;
- QVERIFY(object.property("").isValid() == false);
- QVERIFY(object.property("foo").isValid() == false);
- }
-
- // Valid object - no default
- {
- QByteArray qml = "import Qt 4.6\n"
- "Item {\n"
- " x: 10\n"
- " y: 12\n"
- "}\n";
-
- QmlDomDocument document;
- QVERIFY(document.load(&engine, qml));
-
- QmlDomObject rootObject = document.rootObject();
- QVERIFY(rootObject.isValid());
-
- QVERIFY(rootObject.property("").isValid() == false);
- QVERIFY(rootObject.property("foo").isValid() == false);
-
- QmlDomProperty x = rootObject.property("x");
- QVERIFY(x.isValid());
- QVERIFY(x.propertyName() == "x");
- QVERIFY(x.propertyNameParts().count() == 1);
- QVERIFY(x.propertyNameParts().at(0) == "x");
- QVERIFY(x.isDefaultProperty() == false);
- QVERIFY(x.value().isLiteral());
- QVERIFY(x.value().toLiteral().literal() == "10");
- QCOMPARE(x.position(), 25);
- QCOMPARE(x.length(), 1);
-
- QmlDomProperty y = rootObject.property("y");
- QVERIFY(y.isValid());
- QVERIFY(y.propertyName() == "y");
- QVERIFY(y.propertyNameParts().count() == 1);
- QVERIFY(y.propertyNameParts().at(0) == "y");
- QVERIFY(y.isDefaultProperty() == false);
- QVERIFY(y.value().isLiteral());
- QVERIFY(y.value().toLiteral().literal() == "12");
- QCOMPARE(y.position(), 35);
- QCOMPARE(y.length(), 1);
- }
-
- // Valid object - with default
- {
- QByteArray qml = "import Qt 4.6\n"
- "Item {\n"
- " x: 10\n"
- " y: 12\n"
- " Item {}\n"
- "}\n";
-
- QmlDomDocument document;
- QVERIFY(document.load(&engine, qml));
-
- QmlDomObject rootObject = document.rootObject();
- QVERIFY(rootObject.isValid());
-
- QVERIFY(rootObject.property("").isValid() == false);
- QVERIFY(rootObject.property("foo").isValid() == false);
-
- QmlDomProperty x = rootObject.property("x");
- QVERIFY(x.isValid());
- QVERIFY(x.propertyName() == "x");
- QVERIFY(x.propertyNameParts().count() == 1);
- QVERIFY(x.propertyNameParts().at(0) == "x");
- QVERIFY(x.isDefaultProperty() == false);
- QVERIFY(x.value().isLiteral());
- QVERIFY(x.value().toLiteral().literal() == "10");
- QCOMPARE(x.position(), 25);
- QCOMPARE(x.length(), 1);
-
- QmlDomProperty y = rootObject.property("y");
- QVERIFY(y.isValid());
- QVERIFY(y.propertyName() == "y");
- QVERIFY(y.propertyNameParts().count() == 1);
- QVERIFY(y.propertyNameParts().at(0) == "y");
- QVERIFY(y.isDefaultProperty() == false);
- QVERIFY(y.value().isLiteral());
- QVERIFY(y.value().toLiteral().literal() == "12");
- QCOMPARE(y.position(), 35);
- QCOMPARE(y.length(), 1);
-
- QmlDomProperty data = rootObject.property("data");
- QVERIFY(data.isValid());
- QVERIFY(data.propertyName() == "data");
- QVERIFY(data.propertyNameParts().count() == 1);
- QVERIFY(data.propertyNameParts().at(0) == "data");
- QVERIFY(data.isDefaultProperty() == true);
- QVERIFY(data.value().isList());
- QCOMPARE(data.position(), 45);
- QCOMPARE(data.length(), 0);
- }
-}
-
-// Tests the QmlDomObject::url() method
-void tst_qmldom::object_url()
-{
- // Invalid object
- {
- QmlDomObject object;
- QCOMPARE(object.url(), QUrl());
- }
-
- // Valid builtin object
- {
- QByteArray qml = "import Qt 4.6\n"
- "Item {}";
-
- QmlDomDocument document;
- QVERIFY(document.load(&engine, qml));
-
- QmlDomObject rootObject = document.rootObject();
- QVERIFY(rootObject.isValid());
- QCOMPARE(rootObject.url(), QUrl());
- }
-
- // Valid composite object
- {
- QByteArray qml = "import Qt 4.6\n"
- "MyItem {}";
-
- QUrl myUrl = QUrl::fromLocalFile(SRCDIR "/data/main.qml");
- QUrl subUrl = QUrl::fromLocalFile(SRCDIR "/data/MyItem.qml");
-
- QmlDomDocument document;
- QVERIFY(document.load(&engine, qml, myUrl));
-
- QmlDomObject rootObject = document.rootObject();
- QVERIFY(rootObject.isValid());
- QCOMPARE(rootObject.url(), subUrl);
- }
-}
-
-// Test copy constructors and operators
-void tst_qmldom::copy()
-{
- QByteArray qml = "import Qt 4.6\n"
- "MyItem {\n"
- " id: myItem\n"
- " property int a: 10\n"
- " x: 10\n"
- " y: x + 10\n"
- " z: NumberAnimation {}\n"
- " opacity: Behavior {}\n"
- " Component {\n"
- " Item{}\n"
- " }\n"
- " children: [ Item{}, Item{} ]\n"
- "}\n";
-
- QUrl myUrl = QUrl::fromLocalFile(SRCDIR "/data/main.qml");
-
- QmlDomDocument document;
- QVERIFY(document.load(&engine, qml, myUrl));
-
- // QmlDomDocument
- {
- QmlDomDocument document2(document);
- QmlDomDocument document3;
- document3 = document;
-
- QCOMPARE(document.imports().count(), document2.imports().count());
- QCOMPARE(document.errors().count(), document2.errors().count());
- QCOMPARE(document.rootObject().objectClassName(), document2.rootObject().objectClassName());
-
- QCOMPARE(document.imports().count(), document3.imports().count());
- QCOMPARE(document.errors().count(), document3.errors().count());
- QCOMPARE(document.rootObject().objectClassName(), document3.rootObject().objectClassName());
- }
-
- // QmlDomImport
- {
- QCOMPARE(document.imports().count(), 1);
- QmlDomImport import = document.imports().at(0);
-
- QmlDomImport import2(import);
- QmlDomImport import3;
- import3 = import2;
-
- QCOMPARE(import.type(), import2.type());
- QCOMPARE(import.uri(), import2.uri());
- QCOMPARE(import.version(), import2.version());
- QCOMPARE(import.qualifier(), import2.qualifier());
-
- QCOMPARE(import.type(), import3.type());
- QCOMPARE(import.uri(), import3.uri());
- QCOMPARE(import.version(), import3.version());
- QCOMPARE(import.qualifier(), import3.qualifier());
- }
-
- // QmlDomObject
- {
- QmlDomObject object = document.rootObject();
- QVERIFY(object.isValid());
-
- QmlDomObject object2(object);
- QmlDomObject object3;
- object3 = object;
-
- QCOMPARE(object.isValid(), object2.isValid());
- QCOMPARE(object.objectType(), object2.objectType());
- QCOMPARE(object.objectClassName(), object2.objectClassName());
- QCOMPARE(object.objectTypeMajorVersion(), object2.objectTypeMajorVersion());
- QCOMPARE(object.objectTypeMinorVersion(), object2.objectTypeMinorVersion());
- QCOMPARE(object.objectId(), object2.objectId());
- QCOMPARE(object.properties().count(), object2.properties().count());
- QCOMPARE(object.dynamicProperties().count(), object2.dynamicProperties().count());
- QCOMPARE(object.isCustomType(), object2.isCustomType());
- QCOMPARE(object.customTypeData(), object2.customTypeData());
- QCOMPARE(object.isComponent(), object2.isComponent());
- QCOMPARE(object.position(), object2.position());
- QCOMPARE(object.length(), object2.length());
- QCOMPARE(object.url(), object2.url());
-
- QCOMPARE(object.isValid(), object3.isValid());
- QCOMPARE(object.objectType(), object3.objectType());
- QCOMPARE(object.objectClassName(), object3.objectClassName());
- QCOMPARE(object.objectTypeMajorVersion(), object3.objectTypeMajorVersion());
- QCOMPARE(object.objectTypeMinorVersion(), object3.objectTypeMinorVersion());
- QCOMPARE(object.objectId(), object3.objectId());
- QCOMPARE(object.properties().count(), object3.properties().count());
- QCOMPARE(object.dynamicProperties().count(), object3.dynamicProperties().count());
- QCOMPARE(object.isCustomType(), object3.isCustomType());
- QCOMPARE(object.customTypeData(), object3.customTypeData());
- QCOMPARE(object.isComponent(), object3.isComponent());
- QCOMPARE(object.position(), object3.position());
- QCOMPARE(object.length(), object3.length());
- QCOMPARE(object.url(), object3.url());
- }
-
- // QmlDomDynamicProperty
- {
- QmlDomObject object = document.rootObject();
- QmlDomDynamicProperty property = object.dynamicProperty("a");
-
- QmlDomDynamicProperty property2(property);
- QmlDomDynamicProperty property3;
- property3 = property;
-
- QCOMPARE(property.isValid(), property2.isValid());
- QCOMPARE(property.propertyName(), property2.propertyName());
- QCOMPARE(property.propertyType(), property2.propertyType());
- QCOMPARE(property.propertyTypeName(), property2.propertyTypeName());
- QCOMPARE(property.isDefaultProperty(), property2.isDefaultProperty());
- QCOMPARE(property.defaultValue().propertyName(), property2.defaultValue().propertyName());
- QCOMPARE(property.position(), property2.position());
- QCOMPARE(property.length(), property2.length());
-
- QCOMPARE(property.isValid(), property3.isValid());
- QCOMPARE(property.propertyName(), property3.propertyName());
- QCOMPARE(property.propertyType(), property3.propertyType());
- QCOMPARE(property.propertyTypeName(), property3.propertyTypeName());
- QCOMPARE(property.isDefaultProperty(), property3.isDefaultProperty());
- QCOMPARE(property.defaultValue().propertyName(), property3.defaultValue().propertyName());
- QCOMPARE(property.position(), property3.position());
- QCOMPARE(property.length(), property3.length());
- }
-
- // QmlDomProperty
- {
- QmlDomObject object = document.rootObject();
- QmlDomProperty property = object.property("opacity");
-
- QmlDomProperty property2(property);
- QmlDomProperty property3;
- property3 = property;
-
- QCOMPARE(property.isValid(), property2.isValid());
- QCOMPARE(property.propertyName(), property2.propertyName());
- QCOMPARE(property.propertyNameParts(), property2.propertyNameParts());
- QCOMPARE(property.isDefaultProperty(), property2.isDefaultProperty());
- QCOMPARE(property.value().type(), property2.value().type());
- QCOMPARE(property.position(), property2.position());
- QCOMPARE(property.length(), property2.length());
-
- QCOMPARE(property.isValid(), property3.isValid());
- QCOMPARE(property.propertyName(), property3.propertyName());
- QCOMPARE(property.propertyNameParts(), property3.propertyNameParts());
- QCOMPARE(property.isDefaultProperty(), property3.isDefaultProperty());
- QCOMPARE(property.value().type(), property3.value().type());
- QCOMPARE(property.position(), property3.position());
- QCOMPARE(property.length(), property3.length());
- }
-
- // QmlDomValueLiteral
- {
- QmlDomObject object = document.rootObject();
- QmlDomProperty property = object.property("x");
- QmlDomValueLiteral literal = property.value().toLiteral();
- QCOMPARE(literal.literal(), QString("10"));
-
- QmlDomValueLiteral literal2(literal);
- QmlDomValueLiteral literal3;
- literal3 = literal2;
-
- QCOMPARE(literal2.literal(), QString("10"));
- QCOMPARE(literal3.literal(), QString("10"));
- }
-
-
- // QmlDomValueBinding
- {
- QmlDomObject object = document.rootObject();
- QmlDomProperty property = object.property("y");
- QmlDomValueBinding binding = property.value().toBinding();
- QCOMPARE(binding.binding(), QString("x + 10"));
-
- QmlDomValueBinding binding2(binding);
- QmlDomValueBinding binding3;
- binding3 = binding2;
-
- QCOMPARE(binding2.binding(), QString("x + 10"));
- QCOMPARE(binding3.binding(), QString("x + 10"));
- }
-
- // QmlDomValueValueSource
- {
- QmlDomObject object = document.rootObject();
- QmlDomProperty property = object.property("z");
- QmlDomValueValueSource source = property.value().toValueSource();
- QCOMPARE(source.object().objectClassName(), QByteArray("NumberAnimation"));
-
- QmlDomValueValueSource source2(source);
- QmlDomValueValueSource source3;
- source3 = source;
-
- QCOMPARE(source2.object().objectClassName(), QByteArray("NumberAnimation"));
- QCOMPARE(source3.object().objectClassName(), QByteArray("NumberAnimation"));
- }
-
- // QmlDomValueValueInterceptor
- {
- QmlDomObject object = document.rootObject();
- QmlDomProperty property = object.property("opacity");
- QmlDomValueValueInterceptor interceptor = property.value().toValueInterceptor();
- QCOMPARE(interceptor.object().objectClassName(), QByteArray("Behavior"));
-
- QmlDomValueValueInterceptor interceptor2(interceptor);
- QmlDomValueValueInterceptor interceptor3;
- interceptor3 = interceptor;
-
- QCOMPARE(interceptor2.object().objectClassName(), QByteArray("Behavior"));
- QCOMPARE(interceptor3.object().objectClassName(), QByteArray("Behavior"));
- }
-
- // QmlDomComponent
- {
- QmlDomObject object = document.rootObject();
- QmlDomProperty property = object.property("data");
- QCOMPARE(property.value().toList().values().count(), 1);
- QmlDomComponent component =
- property.value().toList().values().at(0).toObject().toComponent();
- QCOMPARE(component.componentRoot().objectClassName(), QByteArray("Item"));
-
- QmlDomComponent component2(component);
- QmlDomComponent component3;
- component3 = component;
-
- QCOMPARE(component.componentRoot().objectClassName(), component2.componentRoot().objectClassName());
- QCOMPARE(component.isValid(), component2.isValid());
- QCOMPARE(component.objectType(), component2.objectType());
- QCOMPARE(component.objectClassName(), component2.objectClassName());
- QCOMPARE(component.objectTypeMajorVersion(), component2.objectTypeMajorVersion());
- QCOMPARE(component.objectTypeMinorVersion(), component2.objectTypeMinorVersion());
- QCOMPARE(component.objectId(), component2.objectId());
- QCOMPARE(component.properties().count(), component2.properties().count());
- QCOMPARE(component.dynamicProperties().count(), component2.dynamicProperties().count());
- QCOMPARE(component.isCustomType(), component2.isCustomType());
- QCOMPARE(component.customTypeData(), component2.customTypeData());
- QCOMPARE(component.isComponent(), component2.isComponent());
- QCOMPARE(component.position(), component2.position());
- QCOMPARE(component.length(), component2.length());
- QCOMPARE(component.url(), component2.url());
-
- QCOMPARE(component.componentRoot().objectClassName(), component3.componentRoot().objectClassName());
- QCOMPARE(component.isValid(), component3.isValid());
- QCOMPARE(component.objectType(), component3.objectType());
- QCOMPARE(component.objectClassName(), component3.objectClassName());
- QCOMPARE(component.objectTypeMajorVersion(), component3.objectTypeMajorVersion());
- QCOMPARE(component.objectTypeMinorVersion(), component3.objectTypeMinorVersion());
- QCOMPARE(component.objectId(), component3.objectId());
- QCOMPARE(component.properties().count(), component3.properties().count());
- QCOMPARE(component.dynamicProperties().count(), component3.dynamicProperties().count());
- QCOMPARE(component.isCustomType(), component3.isCustomType());
- QCOMPARE(component.customTypeData(), component3.customTypeData());
- QCOMPARE(component.isComponent(), component3.isComponent());
- QCOMPARE(component.position(), component3.position());
- QCOMPARE(component.length(), component3.length());
- QCOMPARE(component.url(), component3.url());
- }
-
- // QmlDomValue
- {
- QmlDomObject object = document.rootObject();
- QmlDomProperty property = object.property("data");
- QmlDomValue value = property.value();
-
- QmlDomValue value2(value);
- QmlDomValue value3;
- value3 = value;
-
- QCOMPARE(value.type(), value2.type());
- QCOMPARE(value.isInvalid(), value2.isInvalid());
- QCOMPARE(value.isLiteral(), value2.isLiteral());
- QCOMPARE(value.isBinding(), value2.isBinding());
- QCOMPARE(value.isValueSource(), value2.isValueSource());
- QCOMPARE(value.isValueInterceptor(), value2.isValueInterceptor());
- QCOMPARE(value.isObject(), value2.isObject());
- QCOMPARE(value.isList(), value2.isList());
- QCOMPARE(value.position(), value2.position());
- QCOMPARE(value.length(), value2.length());
-
- QCOMPARE(value.type(), value3.type());
- QCOMPARE(value.isInvalid(), value3.isInvalid());
- QCOMPARE(value.isLiteral(), value3.isLiteral());
- QCOMPARE(value.isBinding(), value3.isBinding());
- QCOMPARE(value.isValueSource(), value3.isValueSource());
- QCOMPARE(value.isValueInterceptor(), value3.isValueInterceptor());
- QCOMPARE(value.isObject(), value3.isObject());
- QCOMPARE(value.isList(), value3.isList());
- QCOMPARE(value.position(), value3.position());
- QCOMPARE(value.length(), value3.length());
- }
- {
- QmlDomObject object = document.rootObject();
- QmlDomProperty property = object.property("x");
- QmlDomValue value = property.value();
-
- QmlDomValue value2(value);
- QmlDomValue value3;
- value3 = value;
-
- QCOMPARE(value.type(), value2.type());
- QCOMPARE(value.isInvalid(), value2.isInvalid());
- QCOMPARE(value.isLiteral(), value2.isLiteral());
- QCOMPARE(value.isBinding(), value2.isBinding());
- QCOMPARE(value.isValueSource(), value2.isValueSource());
- QCOMPARE(value.isValueInterceptor(), value2.isValueInterceptor());
- QCOMPARE(value.isObject(), value2.isObject());
- QCOMPARE(value.isList(), value2.isList());
- QCOMPARE(value.position(), value2.position());
- QCOMPARE(value.length(), value2.length());
-
- QCOMPARE(value.type(), value3.type());
- QCOMPARE(value.isInvalid(), value3.isInvalid());
- QCOMPARE(value.isLiteral(), value3.isLiteral());
- QCOMPARE(value.isBinding(), value3.isBinding());
- QCOMPARE(value.isValueSource(), value3.isValueSource());
- QCOMPARE(value.isValueInterceptor(), value3.isValueInterceptor());
- QCOMPARE(value.isObject(), value3.isObject());
- QCOMPARE(value.isList(), value3.isList());
- QCOMPARE(value.position(), value3.position());
- QCOMPARE(value.length(), value3.length());
- }
- {
- QmlDomValue value;
-
- QmlDomValue value2(value);
- QmlDomValue value3;
- value3 = value;
-
- QCOMPARE(value.type(), value2.type());
- QCOMPARE(value.isInvalid(), value2.isInvalid());
- QCOMPARE(value.isLiteral(), value2.isLiteral());
- QCOMPARE(value.isBinding(), value2.isBinding());
- QCOMPARE(value.isValueSource(), value2.isValueSource());
- QCOMPARE(value.isValueInterceptor(), value2.isValueInterceptor());
- QCOMPARE(value.isObject(), value2.isObject());
- QCOMPARE(value.isList(), value2.isList());
- QCOMPARE(value.position(), value2.position());
- QCOMPARE(value.length(), value2.length());
-
- QCOMPARE(value.type(), value3.type());
- QCOMPARE(value.isInvalid(), value3.isInvalid());
- QCOMPARE(value.isLiteral(), value3.isLiteral());
- QCOMPARE(value.isBinding(), value3.isBinding());
- QCOMPARE(value.isValueSource(), value3.isValueSource());
- QCOMPARE(value.isValueInterceptor(), value3.isValueInterceptor());
- QCOMPARE(value.isObject(), value3.isObject());
- QCOMPARE(value.isList(), value3.isList());
- QCOMPARE(value.position(), value3.position());
- QCOMPARE(value.length(), value3.length());
- }
-
- // QmlDomList
- {
- QmlDomObject object = document.rootObject();
- QmlDomProperty property = object.property("children");
- QmlDomList list = property.value().toList();
- QCOMPARE(list.values().count(), 2);
-
- QmlDomList list2(list);
- QmlDomList list3;
- list3 = list2;
-
- QCOMPARE(list.values().count(), list2.values().count());
- QCOMPARE(list.position(), list2.position());
- QCOMPARE(list.length(), list2.length());
- QCOMPARE(list.commaPositions(), list2.commaPositions());
-
- QCOMPARE(list.values().count(), list3.values().count());
- QCOMPARE(list.position(), list3.position());
- QCOMPARE(list.length(), list3.length());
- QCOMPARE(list.commaPositions(), list3.commaPositions());
-
- }
-}
-
-// Tests the position/length of various elements
-void tst_qmldom::position()
-{
- QByteArray qml = "import Qt 4.6\n"
- /*14*/ "Item {\n"
- /*21*/ " id: myItem\n"
- /*36*/ " property int a: 10\n"
- /*59*/ " x: 10\n"
- /*69*/ " y: x + 10\n"
- /*83*/ " z: NumberAnimation {}\n"
- /*109*/ " opacity: Behavior {}\n"
- /*134*/ " Component {\n"
- /*150*/ " Item{}\n"
- /*165*/ " }\n"
- /*171*/ " children: [ Item{}, Item{} ]\n"
- /*204*/ "}\n";
-
-
- QmlDomDocument document;
- QVERIFY(document.load(&engine, qml));
-
- QmlDomObject root = document.rootObject();
-
- // All QmlDomDynamicProperty
- QmlDomDynamicProperty dynProp = root.dynamicProperty("a");
- QCOMPARE(dynProp.position(), 40);
- QCOMPARE(dynProp.length(), 18);
-
- // All QmlDomProperty
- QmlDomProperty x = root.property("x");
- QCOMPARE(x.position(), 63);
- QCOMPARE(x.length(), 1);
-
- QmlDomProperty y = root.property("y");
- QCOMPARE(y.position(), 73);
- QCOMPARE(y.length(), 1);
-
- QmlDomProperty z = root.property("z");
- QCOMPARE(z.position(), 87);
- QCOMPARE(z.length(), 1);
-
- QmlDomProperty opacity = root.property("opacity");
- QCOMPARE(opacity.position(), 113);
- QCOMPARE(opacity.length(), 7);
-
- QmlDomProperty data = root.property("data");
- QCOMPARE(data.position(), 138);
- QCOMPARE(data.length(), 0);
-
- QmlDomProperty children = root.property("children");
- QCOMPARE(children.position(), 175);
- QCOMPARE(children.length(), 8);
-
- QmlDomList dataList = data.value().toList();
- QCOMPARE(dataList.values().count(), 1);
- QmlDomList childrenList = children.value().toList();
- QCOMPARE(childrenList.values().count(), 2);
-
- // All QmlDomObject
- QCOMPARE(root.position(), 14);
- QCOMPARE(root.length(), 191);
-
- QmlDomObject numberAnimation = z.value().toValueSource().object();
- QCOMPARE(numberAnimation.position(), 90);
- QCOMPARE(numberAnimation.length(), 18);
-
- QmlDomObject behavior = opacity.value().toValueInterceptor().object();
- QCOMPARE(behavior.position(), 122);
- QCOMPARE(behavior.length(), 11);
-
- QmlDomObject component = dataList.values().at(0).toObject();
- QCOMPARE(component.position(), 138);
- QCOMPARE(component.length(), 32);
-
- QmlDomObject componentRoot = component.toComponent().componentRoot();
- QCOMPARE(componentRoot.position(), 158);
- QCOMPARE(componentRoot.length(), 6);
-
- QmlDomObject child1 = childrenList.values().at(0).toObject();
- QCOMPARE(child1.position(), 187);
- QCOMPARE(child1.length(), 6);
-
- QmlDomObject child2 = childrenList.values().at(1).toObject();
- QCOMPARE(child2.position(), 195);
- QCOMPARE(child2.length(), 6);
-
- // All QmlDomValue
- QmlDomValue xValue = x.value();
- QCOMPARE(xValue.position(), 66);
- QCOMPARE(xValue.length(), 2);
-
- QmlDomValue yValue = y.value();
- QCOMPARE(yValue.position(), 76);
- QCOMPARE(yValue.length(), 6);
-
- QmlDomValue zValue = z.value();
- QCOMPARE(zValue.position(), 90);
- QCOMPARE(zValue.length(), 18);
-
- QmlDomValue opacityValue = opacity.value();
- QCOMPARE(opacityValue.position(), 122);
- QCOMPARE(opacityValue.length(), 11);
-
- QmlDomValue dataValue = data.value();
- QCOMPARE(dataValue.position(), 138);
- QCOMPARE(dataValue.length(), 32);
-
- QmlDomValue child1Value = childrenList.values().at(0);
- QCOMPARE(child1Value.position(), 187);
- QCOMPARE(child1Value.length(), 6);
-
- QmlDomValue child2Value = childrenList.values().at(1);
- QCOMPARE(child2Value.position(), 195);
- QCOMPARE(child2Value.length(), 6);
-
- // All QmlDomList
- qWarning("QmlListValue position test required");
-}
-
-QTEST_MAIN(tst_qmldom)
-
-#include "tst_qmldom.moc"
diff --git a/tests/auto/declarative/qmleasefollow/qmleasefollow.pro b/tests/auto/declarative/qmleasefollow/qmleasefollow.pro
deleted file mode 100644
index 4224a7e..0000000
--- a/tests/auto/declarative/qmleasefollow/qmleasefollow.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative gui
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qmleasefollow.cpp
-
-# Define SRCDIR equal to test's source directory
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmleasefollow/tst_qmleasefollow.cpp b/tests/auto/declarative/qmleasefollow/tst_qmleasefollow.cpp
deleted file mode 100644
index f28311f..0000000
--- a/tests/auto/declarative/qmleasefollow/tst_qmleasefollow.cpp
+++ /dev/null
@@ -1,122 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtDeclarative/qmlengine.h>
-#include <QtDeclarative/qmlcomponent.h>
-#include <private/qmleasefollow_p.h>
-#include <private/qmlvaluetype_p.h>
-#include "../../../shared/util.h"
-
-class tst_qmleasefollow : public QObject
-{
- Q_OBJECT
-public:
- tst_qmleasefollow();
-
-private slots:
- void defaultValues();
- void values();
- void disabled();
-
-private:
- QmlEngine engine;
-};
-
-tst_qmleasefollow::tst_qmleasefollow()
-{
-}
-
-void tst_qmleasefollow::defaultValues()
-{
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/easefollow1.qml"));
- QmlEaseFollow *obj = qobject_cast<QmlEaseFollow*>(c.create());
-
- QVERIFY(obj != 0);
-
- QCOMPARE(obj->sourceValue(), 0.);
- QCOMPARE(obj->velocity(), 200.);
- QCOMPARE(obj->enabled(), true);
- QCOMPARE(obj->duration(), -1.);
- QCOMPARE(obj->maximumEasingTime(), -1.);
- QCOMPARE(obj->reversingMode(), QmlEaseFollow::Eased);
-
- delete obj;
-}
-
-void tst_qmleasefollow::values()
-{
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/easefollow2.qml"));
- QmlEaseFollow *obj = qobject_cast<QmlEaseFollow*>(c.create());
-
- QVERIFY(obj != 0);
-
- QCOMPARE(obj->sourceValue(), 10.);
- QCOMPARE(obj->velocity(), 200.);
- QCOMPARE(obj->enabled(), true);
- QCOMPARE(obj->duration(), 300.);
- QCOMPARE(obj->maximumEasingTime(), -1.);
- QCOMPARE(obj->reversingMode(), QmlEaseFollow::Immediate);
-
- delete obj;
-}
-
-void tst_qmleasefollow::disabled()
-{
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/easefollow3.qml"));
- QmlEaseFollow *obj = qobject_cast<QmlEaseFollow*>(c.create());
-
- QVERIFY(obj != 0);
-
- QCOMPARE(obj->sourceValue(), 10.);
- QCOMPARE(obj->velocity(), 250.);
- QCOMPARE(obj->enabled(), false);
- QCOMPARE(obj->maximumEasingTime(), 150.);
- QCOMPARE(obj->reversingMode(), QmlEaseFollow::Sync);
-
- delete obj;
-}
-
-QTEST_MAIN(tst_qmleasefollow)
-
-#include "tst_qmleasefollow.moc"
diff --git a/tests/auto/declarative/qmlecmascript/qmlecmascript.pro b/tests/auto/declarative/qmlecmascript/qmlecmascript.pro
deleted file mode 100644
index 9f592e8..0000000
--- a/tests/auto/declarative/qmlecmascript/qmlecmascript.pro
+++ /dev/null
@@ -1,10 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative script
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qmlecmascript.cpp \
- testtypes.cpp
-HEADERS += testtypes.h
-
-# QMAKE_CXXFLAGS = -fprofile-arcs -ftest-coverage
-# LIBS += -lgcov
diff --git a/tests/auto/declarative/qmlecmascript/testtypes.cpp b/tests/auto/declarative/qmlecmascript/testtypes.cpp
deleted file mode 100644
index 3c6b256..0000000
--- a/tests/auto/declarative/qmlecmascript/testtypes.cpp
+++ /dev/null
@@ -1,82 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include "testtypes.h"
-
-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;
-};
-
-QML_DEFINE_TYPE(Qt.test, 1,0, MyQmlObject,MyQmlObject);
-QML_DEFINE_TYPE(Qt.test, 1,0, MyDeferredObject,MyDeferredObject);
-QML_DEFINE_TYPE(Qt.test, 1,0, MyQmlContainer,MyQmlContainer);
-QML_DEFINE_EXTENDED_TYPE(Qt.test, 1,0, MyBaseExtendedObject,MyBaseExtendedObject,BaseExtensionObject);
-QML_DEFINE_EXTENDED_TYPE(Qt.test, 1,0, MyExtendedObject,MyExtendedObject,ExtensionObject);
-QML_DEFINE_TYPE(Qt.test, 1,0, MyTypeObject, MyTypeObject);
-
-#include "testtypes.moc"
diff --git a/tests/auto/declarative/qmlecmascript/testtypes.h b/tests/auto/declarative/qmlecmascript/testtypes.h
deleted file mode 100644
index 0af72cb..0000000
--- a/tests/auto/declarative/qmlecmascript/testtypes.h
+++ /dev/null
@@ -1,592 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef TESTTYPES_H
-#define TESTTYPES_H
-
-#include <QtCore/qobject.h>
-#include <QtDeclarative/qml.h>
-#include <QtDeclarative/qmlexpression.h>
-#include <QtCore/qpoint.h>
-#include <QtCore/qsize.h>
-#include <QtDeclarative/qmllist.h>
-#include <QtCore/qrect.h>
-#include <QtGui/qmatrix.h>
-#include <QtGui/qcolor.h>
-#include <QtGui/qvector3d.h>
-#include <QtCore/qdatetime.h>
-#include <QtScript/qscriptvalue.h>
-#include <QtDeclarative/qmlscriptstring.h>
-#include <QtDeclarative/qmlcomponent.h>
-
-class MyQmlAttachedObject : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(int value READ value CONSTANT)
-public:
- MyQmlAttachedObject(QObject *parent) : QObject(parent) {}
-
- int value() const { return 19; }
-};
-
-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(QString stringProperty READ stringProperty WRITE setStringProperty NOTIFY stringChanged)
- Q_PROPERTY(QObject *objectProperty READ objectProperty WRITE setObjectProperty NOTIFY objectChanged)
- Q_PROPERTY(QmlListProperty<QObject> objectListProperty READ objectListProperty CONSTANT)
- Q_PROPERTY(int resettableProperty READ resettableProperty WRITE setResettableProperty RESET resetProperty)
-
-public:
- MyQmlObject(): m_methodCalled(false), m_methodIntCalled(false), m_object(0), m_value(0), m_resetProperty(13) {}
-
- enum MyEnum { EnumValue1 = 0, EnumValue2 = 1 };
- enum MyEnum2 { EnumValue3 = 2, EnumValue4 = 3 };
-
- 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();
- }
-
- QObject *objectProperty() const { return m_object; }
- void setObjectProperty(QObject *obj) {
- if (obj == m_object)
- return;
- m_object = obj;
- emit objectChanged();
- }
-
- QmlListProperty<QObject> objectListProperty() { return QmlListProperty<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; }
-
-signals:
- void basicSignal();
- void argumentSignal(int a, QString b, qreal c);
- void stringChanged();
- void objectChanged();
- void anotherBasicSignal();
- void thirdBasicSignal();
-
-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; }
-
-private:
- friend class tst_qmlecmascript;
- bool m_methodCalled;
- bool m_methodIntCalled;
-
- QObject *m_object;
- QString m_string;
- QList<QObject *> m_objectQList;
- int m_value;
- int m_resetProperty;
-};
-
-QML_DECLARE_TYPEINFO(MyQmlObject, QML_HAS_ATTACHED_PROPERTIES)
-QML_DECLARE_TYPE(MyQmlObject);
-
-class MyQmlContainer : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(QmlListProperty<MyQmlObject> children READ children CONSTANT)
-public:
- MyQmlContainer() {}
-
- QmlListProperty<MyQmlObject> children() { return QmlListProperty<MyQmlObject>(this, m_children); }
-
-private:
- QList<MyQmlObject*> m_children;
-};
-
-QML_DECLARE_TYPE(MyQmlContainer);
-
-class MyExpression : public QmlExpression
-{
-public:
- MyExpression(QmlContext *ctxt, const QString &expr)
- : QmlExpression(ctxt, expr, 0), changed(false)
- {
- }
-
- void emitValueChanged() {
- changed = true;
- QmlExpression::emitValueChanged();
- }
- bool changed;
-};
-
-
-class MyDefaultObject1 : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(int horseLegs READ horseLegs CONSTANT);
- Q_PROPERTY(int antLegs READ antLegs CONSTANT);
-public:
- int horseLegs() const { return 4; }
- int antLegs() const { return 6; }
-};
-
-class MyDefaultObject2 : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(int antLegs READ antLegs CONSTANT);
- Q_PROPERTY(int emuLegs READ emuLegs CONSTANT);
-public:
- int antLegs() const { return 5; } // Had an accident
- 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;
-};
-QML_DECLARE_TYPE(MyDeferredObject);
-
-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;
-};
-QML_DECLARE_TYPE(MyBaseExtendedObject);
-
-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;
-};
-QML_DECLARE_TYPE(MyExtendedObject);
-
-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(QmlComponent *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(QmlScriptString 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;
- }
-
- QmlComponent *componentPropertyValue;
- QmlComponent *componentProperty() const {
- return componentPropertyValue;
- }
- void setComponentProperty(QmlComponent *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;
- }
-
- QmlScriptString scriptPropertyValue;
- QmlScriptString scriptProperty() const {
- return scriptPropertyValue;
- }
- void setScriptProperty(const QmlScriptString &v) {
- scriptPropertyValue = v;
- }
-
- void doAction() { emit action(); }
-signals:
- void action();
- void rectPropertyChanged();
-};
-Q_DECLARE_OPERATORS_FOR_FLAGS(MyTypeObject::MyFlags)
-QML_DECLARE_TYPE(MyTypeObject);
-
-Q_DECLARE_METATYPE(QScriptValue);
-class MyInvokableObject : public QObject
-{
- Q_OBJECT
-public:
- 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.7; }
- 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 QScriptValue method_NoArgs_QScriptValue() { invoke(6); return QScriptValue("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(QScriptValue a) { invoke(14); m_actuals << qVariantFromValue(a); }
- Q_INVOKABLE void method_intQScriptValue(int a, QScriptValue 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; }
-
-private:
- void invoke(int idx) { if (m_invoked != -1) m_invokedError = true; m_invoked = idx;}
- int m_invoked;
- bool m_invokedError;
- QVariantList m_actuals;
-};
-
-#endif // TESTTYPES_H
-
diff --git a/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp b/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp
deleted file mode 100644
index b30ad1c..0000000
--- a/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp
+++ /dev/null
@@ -1,1659 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtDeclarative/qmlcomponent.h>
-#include <QtDeclarative/qmlengine.h>
-#include <QtDeclarative/qmlexpression.h>
-#include <QtDeclarative/qmlcontext.h>
-#include <QtCore/qfileinfo.h>
-#include <QtCore/qdebug.h>
-#include <QtDeclarative/private/qmlguard_p.h>
-#include <QtCore/qdir.h>
-#include <QtCore/qnumeric.h>
-#include <private/qmlengine_p.h>
-#include <private/qmlglobalscriptclass_p.h>
-#include "testtypes.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
-*/
-inline QUrl TEST_FILE(const QString &filename)
-{
- QFileInfo fileInfo(__FILE__);
- return QUrl::fromLocalFile(fileInfo.absoluteDir().filePath("data/" + filename));
-}
-
-inline QUrl TEST_FILE(const char *filename)
-{
- return TEST_FILE(QLatin1String(filename));
-}
-
-class tst_qmlecmascript : public QObject
-{
- Q_OBJECT
-public:
- tst_qmlecmascript() {}
-
-private slots:
- 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 extensionObjects();
- void attachedProperties();
- void enums();
- void valueTypeFunctions();
- void constantsOverrideBindings();
- void outerBindingOverridesInnerBinding();
- void aliasPropertyAndBinding();
- void nonExistantAttachedObject();
- void scope();
- void signalParameterTypes();
- void objectsCompareAsEqual();
- void scriptAccess();
- void dynamicCreation_data();
- void dynamicCreation();
- void dynamicDestruction();
- void objectToString();
- void selfDeletingBinding();
- void extendedObjectPropertyLookup();
- void scriptErrors();
- void signalTriggeredBindings();
- void listProperties();
- void exceptionClearsOnReeval();
- void exceptionSlotProducesWarning();
- void exceptionBindingProducesWarning();
- void transientErrors();
- void shutdownErrors();
- void externalScript();
- void compositePropertyType();
- void jsObject();
- void undefinedResetsProperty();
- void listToVariant();
- void multiEngineObject();
- void deletedObject();
-
- void bug1();
-
- void callQtInvokables();
-private:
- QmlEngine engine;
-};
-
-void tst_qmlecmascript::assignBasicTypes()
-{
- {
- QmlComponent component(&engine, TEST_FILE("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.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->urlProperty(), component.url().resolved(QUrl("main.qml")));
- delete object;
- }
- {
- QmlComponent component(&engine, TEST_FILE("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.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->urlProperty(), component.url().resolved(QUrl("main.qml")));
- delete object;
- }
-}
-
-void tst_qmlecmascript::idShortcutInvalidates()
-{
- {
- QmlComponent component(&engine, TEST_FILE("idShortcutInvalidates.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
- QVERIFY(object->objectProperty() != 0);
- delete object->objectProperty();
- QVERIFY(object->objectProperty() == 0);
- }
-
- {
- QmlComponent component(&engine, TEST_FILE("idShortcutInvalidates.1.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
- QVERIFY(object->objectProperty() != 0);
- delete object->objectProperty();
- QVERIFY(object->objectProperty() == 0);
- }
-}
-
-void tst_qmlecmascript::boolPropertiesEvaluateAsBool()
-{
- {
- QmlComponent component(&engine, TEST_FILE("boolPropertiesEvaluateAsBool.1.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->stringProperty(), QLatin1String("pass"));
- }
- {
- QmlComponent component(&engine, TEST_FILE("boolPropertiesEvaluateAsBool.2.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->stringProperty(), QLatin1String("pass"));
- }
-}
-
-void tst_qmlecmascript::signalAssignment()
-{
- {
- QmlComponent component(&engine, TEST_FILE("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"));
- }
-
- {
- QmlComponent component(&engine, TEST_FILE("signalAssignment.2.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->string(), QString());
- emit object->argumentSignal(19, "Hello world!", 10.3);
- QCOMPARE(object->string(), QString("pass 19 Hello world! 10.3"));
- }
-}
-
-void tst_qmlecmascript::methods()
-{
- {
- QmlComponent component(&engine, TEST_FILE("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);
- }
-
- {
- QmlComponent component(&engine, TEST_FILE("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);
- }
-
- {
- QmlComponent component(&engine, TEST_FILE("methods.3.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- QCOMPARE(object->property("test").toInt(), 19);
- }
-
- {
- QmlComponent component(&engine, TEST_FILE("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);
- }
-
- {
- QmlComponent component(&engine, TEST_FILE("methods.5.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- QCOMPARE(object->property("test").toInt(), 9);
- }
-}
-
-void tst_qmlecmascript::bindingLoop()
-{
- QmlComponent component(&engine, TEST_FILE("bindingLoop.qml"));
- QString warning = "QML MyQmlObject (" + component.url().toString() + ":9:9) Binding loop detected for property \"stringProperty\"";
- QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData());
- QObject *object = component.create();
- QVERIFY(object != 0);
-}
-
-void tst_qmlecmascript::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_qmlecmascript::basicExpressions()
-{
- QFETCH(QString, expression);
- QFETCH(QVariant, result);
- QFETCH(bool, nest);
-
- MyQmlObject object1;
- MyQmlObject object2;
- MyQmlObject object3;
- MyDefaultObject1 default1;
- MyDefaultObject2 default2;
- MyDefaultObject3 default3;
- object1.setStringProperty("Object1");
- object2.setStringProperty("Object2");
- object3.setStringProperty("Object3");
-
- QmlContext context(engine.rootContext());
- QmlContext nestedContext(&context);
-
- context.addDefaultObject(&default1);
- context.addDefaultObject(&default2);
- context.setContextProperty("a", QVariant(1944));
- context.setContextProperty("b", QVariant("Milk"));
- context.setContextProperty("object", &object1);
- context.setContextProperty("objectOverride", &object2);
- nestedContext.addDefaultObject(&default3);
- nestedContext.setContextProperty("b", QVariant("Cow"));
- nestedContext.setContextProperty("objectOverride", &object3);
- nestedContext.setContextProperty("millipedeLegs", QVariant(100));
-
- MyExpression expr(nest?&nestedContext:&context, expression);
- QCOMPARE(expr.value(), result);
-}
-
-void tst_qmlecmascript::arrayExpressions()
-{
- QObject obj1;
- QObject obj2;
- QObject obj3;
-
- QmlContext 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.value();
- 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_qmlecmascript::contextPropertiesTriggerReeval()
-{
- QmlContext 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.value(), QVariant(2));
-
- context.setContextProperty("testProp", QVariant(2));
- QCOMPARE(expr.changed, true);
- QCOMPARE(expr.value(), QVariant(3));
- }
-
- {
- MyExpression expr(&context, "testProp + testProp + testProp");
- QCOMPARE(expr.changed, false);
- QCOMPARE(expr.value(), QVariant(6));
-
- context.setContextProperty("testProp", QVariant(4));
- QCOMPARE(expr.changed, true);
- QCOMPARE(expr.value(), QVariant(12));
- }
-
- {
- MyExpression expr(&context, "testObj.stringProperty");
- QCOMPARE(expr.changed, false);
- QCOMPARE(expr.value(), QVariant("Hello"));
-
- context.setContextProperty("testObj", &object2);
- QCOMPARE(expr.changed, true);
- QCOMPARE(expr.value(), QVariant("World"));
- }
-
- {
- MyExpression expr(&context, "testObj.stringProperty /**/");
- QCOMPARE(expr.changed, false);
- QCOMPARE(expr.value(), QVariant("World"));
-
- context.setContextProperty("testObj", &object1);
- QCOMPARE(expr.changed, true);
- QCOMPARE(expr.value(), QVariant("Hello"));
- }
-
- {
- MyExpression expr(&context, "testObj2");
- QCOMPARE(expr.changed, false);
- QCOMPARE(expr.value(), QVariant::fromValue((QObject *)object3));
- }
-
-}
-
-void tst_qmlecmascript::objectPropertiesTriggerReeval()
-{
- QmlContext 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.value(), QVariant("Hello"));
-
- object1.setStringProperty(QLatin1String("World"));
- QCOMPARE(expr.changed, true);
- QCOMPARE(expr.value(), QVariant("World"));
- }
-
- {
- MyExpression expr(&context, "testObj.objectProperty.stringProperty");
- QCOMPARE(expr.changed, false);
- QCOMPARE(expr.value(), QVariant());
-
- object1.setObjectProperty(&object2);
- QCOMPARE(expr.changed, true);
- expr.changed = false;
- QCOMPARE(expr.value(), QVariant("Dog"));
-
- object1.setObjectProperty(&object3);
- QCOMPARE(expr.changed, true);
- expr.changed = false;
- QCOMPARE(expr.value(), QVariant("Cat"));
-
- object1.setObjectProperty(0);
- QCOMPARE(expr.changed, true);
- expr.changed = false;
- QCOMPARE(expr.value(), QVariant());
-
- object1.setObjectProperty(&object3);
- QCOMPARE(expr.changed, true);
- expr.changed = false;
- QCOMPARE(expr.value(), QVariant("Cat"));
-
- object3.setStringProperty("Donkey");
- QCOMPARE(expr.changed, true);
- expr.changed = false;
- QCOMPARE(expr.value(), QVariant("Donkey"));
- }
-}
-
-void tst_qmlecmascript::deferredProperties()
-{
- QmlComponent component(&engine, TEST_FILE("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);
-}
-
-void tst_qmlecmascript::extensionObjects()
-{
- QmlComponent component(&engine, TEST_FILE("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);
-}
-
-void tst_qmlecmascript::attachedProperties()
-{
- QmlComponent component(&engine, TEST_FILE("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);
-
- // ### Need to test attached property assignment
-}
-
-void tst_qmlecmascript::enums()
-{
- // Existant enums
- {
- QmlComponent component(&engine, TEST_FILE("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);
- }
- // Non-existent enums
- {
- QmlComponent component(&engine, TEST_FILE("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);
- }
-}
-
-void tst_qmlecmascript::valueTypeFunctions()
-{
- QmlComponent component(&engine, TEST_FILE("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));
-}
-
-/*
-Tests that writing a constant to a property with a binding on it disables the
-binding.
-*/
-void tst_qmlecmascript::constantsOverrideBindings()
-{
- // From ECMAScript
- {
- QmlComponent component(&engine, TEST_FILE("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);
- }
-
- // During construction
- {
- QmlComponent component(&engine, TEST_FILE("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);
- }
-
-#if 0
- // From C++
- {
- QmlComponent component(&engine, TEST_FILE("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);
- }
-#endif
-}
-
-/*
-Tests that assigning a binding to a property that already has a binding causes
-the original binding to be disabled.
-*/
-void tst_qmlecmascript::outerBindingOverridesInnerBinding()
-{
- QmlComponent component(&engine,
- TEST_FILE("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);
-}
-
-/*
-Access a non-existent attached object.
-
-Tests for a regression where this used to crash.
-*/
-void tst_qmlecmascript::nonExistantAttachedObject()
-{
- QmlComponent component(&engine, TEST_FILE("nonExistantAttachedObject.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);
-}
-
-void tst_qmlecmascript::scope()
-{
- {
- QmlComponent component(&engine, TEST_FILE("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);
- }
-
- {
- QmlComponent component(&engine, TEST_FILE("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(), 11);
- QCOMPARE(object->property("test4").toInt(), 11);
- QCOMPARE(object->property("test5").toInt(), 24);
- QCOMPARE(object->property("test6").toInt(), 24);
- }
-}
-
-/*
-Tests that "any" type passes through a synthesized signal parameter. This
-is essentially a test of QmlMetaType::copy()
-*/
-void tst_qmlecmascript::signalParameterTypes()
-{
- QmlComponent component(&engine, TEST_FILE("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)));
-}
-
-/*
-Test that two JS objects for the same QObject compare as equal.
-*/
-void tst_qmlecmascript::objectsCompareAsEqual()
-{
- QmlComponent component(&engine, TEST_FILE("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);
-}
-
-/*
-Confirm bindings and alias properties can coexist.
-
-Tests for a regression where the binding would not reevaluate.
-*/
-void tst_qmlecmascript::aliasPropertyAndBinding()
-{
- QmlComponent component(&engine, TEST_FILE("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);
-}
-
-/*
-Tests that only methods of Script {} blocks are exposed.
-*/
-void tst_qmlecmascript::scriptAccess()
-{
- QmlComponent component(&engine, TEST_FILE("scriptAccess.qml"));
-
- QString warning = component.url().toString() + ":16: Unable to assign [undefined] to int";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test1").toInt(), 10);
- QCOMPARE(object->property("test2").toInt(), 19);
- QCOMPARE(object->property("test3").toInt(), 0);
-}
-
-void tst_qmlecmascript::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_qmlecmascript::dynamicCreation()
-{
- QFETCH(QString, method);
- QFETCH(QString, createdName);
-
- QmlComponent component(&engine, TEST_FILE("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);
-}
-
-/*
- Tests the destroy function
-*/
-void tst_qmlecmascript::dynamicDestruction()
-{
- QmlComponent component(&engine, TEST_FILE("dynamicDeletion.qml"));
- QmlGuard<MyQmlObject> object = qobject_cast<MyQmlObject*>(component.create());
- QVERIFY(object != 0);
- QmlGuard<QObject> createdQmlObject = 0;
-
- QMetaObject::invokeMethod(object, "create");
- createdQmlObject = object->objectProperty();
- QVERIFY(createdQmlObject);
- QCOMPARE(createdQmlObject->objectName(), QString("emptyObject"));
-
- QMetaObject::invokeMethod(object, "killOther");
- QVERIFY(createdQmlObject);
- QCoreApplication::instance()->processEvents(QEventLoop::DeferredDeletion);
- QVERIFY(createdQmlObject);
- for (int ii = 0; createdQmlObject && ii < 50; ++ii) { // After 5 seconds we should give up
- if (createdQmlObject) {
- QTest::qWait(100);
- QCoreApplication::instance()->processEvents(QEventLoop::DeferredDeletion);
- }
- }
- QVERIFY(!createdQmlObject);
-
- QMetaObject::invokeMethod(object, "killMe");
- QVERIFY(object);
- QTest::qWait(0);
- QCoreApplication::instance()->processEvents(QEventLoop::DeferredDeletion);
- QVERIFY(!object);
-}
-
-/*
- tests that id.toString() works
-*/
-void tst_qmlecmascript::objectToString()
-{
- QmlComponent component(&engine, TEST_FILE("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\")"));
-}
-
-/*
-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_qmlecmascript::selfDeletingBinding()
-{
- {
- QmlComponent component(&engine, TEST_FILE("selfDeletingBinding.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- object->setProperty("triggerDelete", true);
- }
-
- {
- QmlComponent component(&engine, TEST_FILE("selfDeletingBinding.2.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- object->setProperty("triggerDelete", true);
- }
-}
-
-/*
-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_qmlecmascript::extendedObjectPropertyLookup()
-{
- QmlComponent component(&engine, TEST_FILE("extendedObjectPropertyLookup.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-}
-
-/*
-Test file/lineNumbers for binding/Script errors.
-*/
-void tst_qmlecmascript::scriptErrors()
-{
- QmlComponent component(&engine, TEST_FILE("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 + ":7: TypeError: Result of expression 'a' [undefined] is not an object.";
- QString warning3 = url + ":5: Error: Invalid write to global property \"a\"";
- QString warning4 = url + ":12: TypeError: Result of expression 'a' [undefined] is not an object.";
- QString warning5 = url + ":10: TypeError: Result of expression 'a' [undefined] is not an object.";
- QString warning6 = url + ":9: Unable to assign [undefined] to int";
- QString warning7 = url + ":14: Error: Cannot assign to read-only property \"trueProperty\"";
- QString warning8 = url + ":15: 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();
-}
-
-/*
-Test bindings still work when the reeval is triggered from within
-a signal script.
-*/
-void tst_qmlecmascript::signalTriggeredBindings()
-{
- QmlComponent component(&engine, TEST_FILE("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);
-
- QCOMPARE(object->property("base").toReal(), 400.);
- QCOMPARE(object->property("test1").toReal(), 400.);
- QCOMPARE(object->property("test2").toReal(), 400.);
-}
-
-/*
-Test that list properties can be iterated from ECMAScript
-*/
-void tst_qmlecmascript::listProperties()
-{
- QmlComponent component(&engine, TEST_FILE("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);
-}
-
-void tst_qmlecmascript::exceptionClearsOnReeval()
-{
- QmlComponent component(&engine, TEST_FILE("exceptionClearsOnReeval.qml"));
- QString url = component.url().toString();
-
- QString warning = url + ":4: TypeError: Result of expression 'objectProperty.objectProperty' [undefined] is not an object.";
-
- 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);
-}
-
-void tst_qmlecmascript::exceptionSlotProducesWarning()
-{
- QmlComponent component(&engine, TEST_FILE("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);
-}
-
-void tst_qmlecmascript::exceptionBindingProducesWarning()
-{
- QmlComponent component(&engine, TEST_FILE("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);
-}
-
-static int transientErrorsMsgCount = 0;
-static void transientErrorsMsgHandler(QtMsgType, const char *)
-{
- ++transientErrorsMsgCount;
-}
-
-// Check that transient binding errors are not displayed
-void tst_qmlecmascript::transientErrors()
-{
- QmlComponent component(&engine, TEST_FILE("transientErrors.qml"));
-
- transientErrorsMsgCount = 0;
- QtMsgHandler old = qInstallMsgHandler(transientErrorsMsgHandler);
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- qInstallMsgHandler(old);
-
- QCOMPARE(transientErrorsMsgCount, 0);
-}
-
-// Check that errors during shutdown are minimized
-void tst_qmlecmascript::shutdownErrors()
-{
- QmlComponent component(&engine, TEST_FILE("shutdownErrors.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- transientErrorsMsgCount = 0;
- QtMsgHandler old = qInstallMsgHandler(transientErrorsMsgHandler);
-
- delete object;
-
- qInstallMsgHandler(old);
- QCOMPARE(transientErrorsMsgCount, 0);
-}
-
-// Check that Script::source property works as expected
-void tst_qmlecmascript::externalScript()
-{
- {
- QmlComponent component(&engine, TEST_FILE("externalScript.1.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toInt(), 92);
-
- delete object;
- }
-
- {
- QmlComponent component(&engine, TEST_FILE("externalScript.2.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toInt(), 92);
-
- delete object;
- }
-
- {
- QmlComponent component(&engine, TEST_FILE("externalScript.3.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toInt(), 92);
- QCOMPARE(object->property("test2").toInt(), 92);
- QCOMPARE(object->property("test3").toBool(), false);
-
- delete object;
- }
-
- {
- QmlComponent component(&engine, TEST_FILE("externalScript.4.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toInt(), 92);
- QCOMPARE(object->property("test2").toBool(), true);
-
- delete object;
- }
-}
-
-void tst_qmlecmascript::compositePropertyType()
-{
- QmlComponent component(&engine, TEST_FILE("compositePropertyType.qml"));
- QTest::ignoreMessage(QtDebugMsg, "hello world");
- QObject *object = qobject_cast<QObject *>(component.create());
- delete object;
-}
-
-// QTBUG-5759
-void tst_qmlecmascript::jsObject()
-{
- QmlComponent component(&engine, TEST_FILE("jsObject.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toInt(), 92);
-
- delete object;
-}
-
-void tst_qmlecmascript::undefinedResetsProperty()
-{
- {
- QmlComponent component(&engine, TEST_FILE("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;
- }
- {
- QmlComponent component(&engine, TEST_FILE("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;
- }
-}
-
-// QTBUG-6781
-void tst_qmlecmascript::bug1()
-{
- QmlComponent component(&engine, TEST_FILE("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_qmlecmascript::callQtInvokables()
-{
- MyInvokableObject o;
-
- QmlEngine qmlengine;
- QmlEnginePrivate *ep = QmlEnginePrivate::get(&qmlengine);
- QScriptEngine *engine = &ep->scriptEngine;
- ep->globalClass->explicitSetProperty("object", ep->objectClass->newQObject(&o));
-
- // Non-existent methods
- o.reset();
- QCOMPARE(engine->evaluate("object.method_nonexistent()").isError(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), -1);
- QCOMPARE(o.actuals().count(), 0);
-
- o.reset();
- QCOMPARE(engine->evaluate("object.method_nonexistent(10, 11)").isError(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), -1);
- QCOMPARE(o.actuals().count(), 0);
-
- // Insufficient arguments
- o.reset();
- QCOMPARE(engine->evaluate("object.method_int()").isError(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), -1);
- QCOMPARE(o.actuals().count(), 0);
-
- o.reset();
- QCOMPARE(engine->evaluate("object.method_intint(10)").isError(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), -1);
- QCOMPARE(o.actuals().count(), 0);
-
- // Excessive arguments
- o.reset();
- QCOMPARE(engine->evaluate("object.method_int(10, 11)").isUndefined(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 8);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant(10));
-
- o.reset();
- QCOMPARE(engine->evaluate("object.method_intint(10, 11, 12)").isUndefined(), true);
- 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();
- QCOMPARE(engine->evaluate("object.method_NoArgs()").isUndefined(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 0);
- QCOMPARE(o.actuals().count(), 0);
-
- o.reset();
- QVERIFY(engine->evaluate("object.method_NoArgs_int()").strictlyEquals(QScriptValue(engine, 6)));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 1);
- QCOMPARE(o.actuals().count(), 0);
-
- o.reset();
- QVERIFY(engine->evaluate("object.method_NoArgs_real()").strictlyEquals(QScriptValue(engine, 19.7)));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 2);
- QCOMPARE(o.actuals().count(), 0);
-
- o.reset();
- {
- QScriptValue ret = engine->evaluate("object.method_NoArgs_QPointF()");
- QVERIFY(ret.isVariant());
- QCOMPARE(ret.toVariant(), QVariant(QPointF(123, 4.5)));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 3);
- QCOMPARE(o.actuals().count(), 0);
- }
-
- o.reset();
- {
- QScriptValue ret = engine->evaluate("object.method_NoArgs_QObject()");
- QVERIFY(ret.isQObject());
- QCOMPARE(ret.toQObject(), (QObject *)&o);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 4);
- QCOMPARE(o.actuals().count(), 0);
- }
-
- o.reset();
- QCOMPARE(engine->evaluate("object.method_NoArgs_unknown()").isUndefined(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 5);
- QCOMPARE(o.actuals().count(), 0);
-
- o.reset();
- {
- QScriptValue ret = engine->evaluate("object.method_NoArgs_QScriptValue()");
- QVERIFY(ret.isString());
- QCOMPARE(ret.toString(), QString("Hello world"));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 6);
- QCOMPARE(o.actuals().count(), 0);
- }
-
- o.reset();
- QVERIFY(engine->evaluate("object.method_NoArgs_QVariant()").strictlyEquals(QScriptValue(engine, "QML rocks")));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 7);
- QCOMPARE(o.actuals().count(), 0);
-
- // Test arg types
- o.reset();
- QCOMPARE(engine->evaluate("object.method_int(94)").isUndefined(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 8);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant(94));
-
- o.reset();
- QCOMPARE(engine->evaluate("object.method_int(\"94\")").isUndefined(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 8);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant(94));
-
- o.reset();
- QCOMPARE(engine->evaluate("object.method_int(\"not a number\")").isUndefined(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 8);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant(0));
-
- o.reset();
- QCOMPARE(engine->evaluate("object.method_int(null)").isUndefined(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 8);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant(0));
-
- o.reset();
- QCOMPARE(engine->evaluate("object.method_int(undefined)").isUndefined(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 8);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant(0));
-
- o.reset();
- QCOMPARE(engine->evaluate("object.method_int(object)").isUndefined(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 8);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant(0));
-
- o.reset();
- QCOMPARE(engine->evaluate("object.method_intint(122, 9)").isUndefined(), true);
- 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();
- QCOMPARE(engine->evaluate("object.method_real(94.3)").isUndefined(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 10);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant(94.3));
-
- o.reset();
- QCOMPARE(engine->evaluate("object.method_real(\"94.3\")").isUndefined(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 10);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant(94.3));
-
- o.reset();
- QCOMPARE(engine->evaluate("object.method_real(\"not a number\")").isUndefined(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 10);
- QCOMPARE(o.actuals().count(), 1);
- QVERIFY(qIsNaN(o.actuals().at(0).toDouble()));
-
- o.reset();
- QCOMPARE(engine->evaluate("object.method_real(null)").isUndefined(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 10);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant(0));
-
- o.reset();
- QCOMPARE(engine->evaluate("object.method_real(undefined)").isUndefined(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 10);
- QCOMPARE(o.actuals().count(), 1);
- QVERIFY(qIsNaN(o.actuals().at(0).toDouble()));
-
- o.reset();
- QCOMPARE(engine->evaluate("object.method_real(object)").isUndefined(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 10);
- QCOMPARE(o.actuals().count(), 1);
- QVERIFY(qIsNaN(o.actuals().at(0).toDouble()));
-
- o.reset();
- QCOMPARE(engine->evaluate("object.method_QString(\"Hello world\")").isUndefined(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 11);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant("Hello world"));
-
- o.reset();
- QCOMPARE(engine->evaluate("object.method_QString(19)").isUndefined(), true);
- 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((intptr_t)&o, 16) + ")";
- QCOMPARE(engine->evaluate("object.method_QString(object)").isUndefined(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 11);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant(expected));
- }
-
- o.reset();
- QCOMPARE(engine->evaluate("object.method_QString(null)").isUndefined(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 11);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant(QString()));
-
- o.reset();
- QCOMPARE(engine->evaluate("object.method_QString(undefined)").isUndefined(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 11);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant(QString()));
-
- o.reset();
- QCOMPARE(engine->evaluate("object.method_QPointF(0)").isUndefined(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 12);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant(QPointF()));
-
- o.reset();
- QCOMPARE(engine->evaluate("object.method_QPointF(null)").isUndefined(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 12);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant(QPointF()));
-
- o.reset();
- QCOMPARE(engine->evaluate("object.method_QPointF(undefined)").isUndefined(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 12);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant(QPointF()));
-
- o.reset();
- QCOMPARE(engine->evaluate("object.method_QPointF(object)").isUndefined(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 12);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant(QPointF()));
-
- o.reset();
- QCOMPARE(engine->evaluate("object.method_QPointF(object.method_get_QPointF())").isUndefined(), true);
- 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();
- QCOMPARE(engine->evaluate("object.method_QPointF(object.method_get_QPoint())").isUndefined(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 12);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant(QPointF(9, 12)));
-
- o.reset();
- QCOMPARE(engine->evaluate("object.method_QObject(0)").isUndefined(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 13);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), qVariantFromValue((QObject *)0));
-
- o.reset();
- QCOMPARE(engine->evaluate("object.method_QObject(\"Hello world\")").isUndefined(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 13);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), qVariantFromValue((QObject *)0));
-
- o.reset();
- QCOMPARE(engine->evaluate("object.method_QObject(null)").isUndefined(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 13);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), qVariantFromValue((QObject *)0));
-
- o.reset();
- QCOMPARE(engine->evaluate("object.method_QObject(undefined)").isUndefined(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 13);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), qVariantFromValue((QObject *)0));
-
- o.reset();
- QCOMPARE(engine->evaluate("object.method_QObject(object)").isUndefined(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 13);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), qVariantFromValue((QObject *)&o));
-
- o.reset();
- QCOMPARE(engine->evaluate("object.method_QScriptValue(null)").isUndefined(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 14);
- QCOMPARE(o.actuals().count(), 1);
- QVERIFY(qvariant_cast<QScriptValue>(o.actuals().at(0)).isNull());
-
- o.reset();
- QCOMPARE(engine->evaluate("object.method_QScriptValue(undefined)").isUndefined(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 14);
- QCOMPARE(o.actuals().count(), 1);
- QVERIFY(qvariant_cast<QScriptValue>(o.actuals().at(0)).isUndefined());
-
- o.reset();
- QCOMPARE(engine->evaluate("object.method_QScriptValue(19)").isUndefined(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 14);
- QCOMPARE(o.actuals().count(), 1);
- QVERIFY(qvariant_cast<QScriptValue>(o.actuals().at(0)).strictlyEquals(QScriptValue(engine, 19)));
-
- o.reset();
- QCOMPARE(engine->evaluate("object.method_QScriptValue([19, 20])").isUndefined(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 14);
- QCOMPARE(o.actuals().count(), 1);
- QVERIFY(qvariant_cast<QScriptValue>(o.actuals().at(0)).isArray());
-
- o.reset();
- QCOMPARE(engine->evaluate("object.method_intQScriptValue(4, null)").isUndefined(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 15);
- QCOMPARE(o.actuals().count(), 2);
- QCOMPARE(o.actuals().at(0), QVariant(4));
- QVERIFY(qvariant_cast<QScriptValue>(o.actuals().at(1)).isNull());
-
- o.reset();
- QCOMPARE(engine->evaluate("object.method_intQScriptValue(8, undefined)").isUndefined(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 15);
- QCOMPARE(o.actuals().count(), 2);
- QCOMPARE(o.actuals().at(0), QVariant(8));
- QVERIFY(qvariant_cast<QScriptValue>(o.actuals().at(1)).isUndefined());
-
- o.reset();
- QCOMPARE(engine->evaluate("object.method_intQScriptValue(3, 19)").isUndefined(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 15);
- QCOMPARE(o.actuals().count(), 2);
- QCOMPARE(o.actuals().at(0), QVariant(3));
- QVERIFY(qvariant_cast<QScriptValue>(o.actuals().at(1)).strictlyEquals(QScriptValue(engine, 19)));
-
- o.reset();
- QCOMPARE(engine->evaluate("object.method_intQScriptValue(44, [19, 20])").isUndefined(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 15);
- QCOMPARE(o.actuals().count(), 2);
- QCOMPARE(o.actuals().at(0), QVariant(44));
- QVERIFY(qvariant_cast<QScriptValue>(o.actuals().at(1)).isArray());
-
- // Test overloads - QML will always invoke the *last* method
- o.reset();
- QCOMPARE(engine->evaluate("object.method_overload()").isError(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), -1);
- QCOMPARE(o.actuals().count(), 0);
-
- o.reset();
- QCOMPARE(engine->evaluate("object.method_overload(10)").isError(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), -1);
- QCOMPARE(o.actuals().count(), 0);
-
- o.reset();
- QCOMPARE(engine->evaluate("object.method_overload(10, 11)").isUndefined(), true);
- 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));
-}
-
-// QTBUG-5675
-void tst_qmlecmascript::listToVariant()
-{
- QmlComponent component(&engine, TEST_FILE("listToVariant.qml"));
-
- MyQmlContainer container;
-
- QmlContext context(engine.rootContext());
- context.addDefaultObject(&container);
-
- QObject *object = component.create(&context);
- QVERIFY(object != 0);
-
- QVariant v = object->property("test");
- QCOMPARE(v.userType(), qMetaTypeId<QmlListReference>());
- QVERIFY(qvariant_cast<QmlListReference>(v).object() == &container);
-
- delete object;
-}
-
-// QTBUG-7957
-void tst_qmlecmascript::multiEngineObject()
-{
- MyQmlObject obj;
- obj.setStringProperty("Howdy planet");
-
- QmlEngine e1;
- e1.rootContext()->setContextProperty("thing", &obj);
- QmlComponent c1(&e1, TEST_FILE("multiEngineObject.qml"));
-
- QmlEngine e2;
- e2.rootContext()->setContextProperty("thing", &obj);
- QmlComponent c2(&e2, TEST_FILE("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_qmlecmascript::deletedObject()
-{
- QmlComponent component(&engine, TEST_FILE("deletedObject.qml"));
-
- QObject *object = component.create();
-
- QCOMPARE(object->property("test1").toBool(), true);
- QCOMPARE(object->property("test2").toBool(), true);
- QCOMPARE(object->property("test3").toBool(), true);
- QEXPECT_FAIL("", "QTBUG-8077", Continue);
- QCOMPARE(object->property("test4").toBool(), true);
-
- delete object;
-}
-
-QTEST_MAIN(tst_qmlecmascript)
-
-#include "tst_qmlecmascript.moc"
diff --git a/tests/auto/declarative/qmlengine/qmlengine.pro b/tests/auto/declarative/qmlengine/qmlengine.pro
deleted file mode 100644
index 1a0e5f4..0000000
--- a/tests/auto/declarative/qmlengine/qmlengine.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative network
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qmlengine.cpp
-
-# Define SRCDIR equal to test's source directory
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmlengine/tst_qmlengine.cpp b/tests/auto/declarative/qmlengine/tst_qmlengine.cpp
deleted file mode 100644
index 6504d03..0000000
--- a/tests/auto/declarative/qmlengine/tst_qmlengine.cpp
+++ /dev/null
@@ -1,240 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qtest.h>
-#include <QmlEngine>
-#include <QmlContext>
-#include <QNetworkAccessManager>
-#include <QPointer>
-#include <QDir>
-#include <QDesktopServices>
-#include <QDebug>
-#include <QmlComponent>
-#include <QmlNetworkAccessManagerFactory>
-
-class tst_qmlengine : public QObject
-{
- Q_OBJECT
-public:
- tst_qmlengine() {}
-
-private slots:
- void rootContext();
- void networkAccessManager();
- void baseUrl();
- void contextForObject();
- void offlineStoragePath();
- void clearComponentCache();
-};
-
-void tst_qmlengine::rootContext()
-{
- QmlEngine engine;
-
- QVERIFY(engine.rootContext());
-
- QCOMPARE(engine.rootContext()->engine(), &engine);
- QVERIFY(engine.rootContext()->parentContext() == 0);
-}
-
-class NetworkAccessManagerFactory : public QmlNetworkAccessManagerFactory
-{
-public:
- NetworkAccessManagerFactory() : manager(0) {}
-
- QNetworkAccessManager *create(QObject *parent) {
- manager = new QNetworkAccessManager(parent);
- return manager;
- }
-
- QNetworkAccessManager *manager;
-};
-
-void tst_qmlengine::networkAccessManager()
-{
- QmlEngine *engine = new QmlEngine;
-
- // Test QmlEngine created manager
- QPointer<QNetworkAccessManager> manager = engine->networkAccessManager();
- QVERIFY(manager != 0);
- delete engine;
-
- // Test factory created manager
- engine = new QmlEngine;
- NetworkAccessManagerFactory factory;
- engine->setNetworkAccessManagerFactory(&factory);
- QVERIFY(engine->networkAccessManager() == factory.manager);
- delete engine;
-}
-
-void tst_qmlengine::baseUrl()
-{
- QmlEngine 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_qmlengine::contextForObject()
-{
- QmlEngine *engine = new QmlEngine;
-
- // Test null-object
- QVERIFY(QmlEngine::contextForObject(0) == 0);
-
- // Test an object with no context
- QObject object;
- QVERIFY(QmlEngine::contextForObject(&object) == 0);
-
- // Test setting null-object
- QmlEngine::setContextForObject(0, engine->rootContext());
-
- // Test setting null-context
- QmlEngine::setContextForObject(&object, 0);
-
- // Test setting context
- QmlEngine::setContextForObject(&object, engine->rootContext());
- QVERIFY(QmlEngine::contextForObject(&object) == engine->rootContext());
-
- QmlContext context(engine->rootContext());
-
- // Try changing context
- QTest::ignoreMessage(QtWarningMsg, "QmlEngine::setContextForObject(): Object already has a QmlContext");
- QmlEngine::setContextForObject(&object, &context);
- QVERIFY(QmlEngine::contextForObject(&object) == engine->rootContext());
-
- // Delete context
- delete engine; engine = 0;
- QVERIFY(QmlEngine::contextForObject(&object) == 0);
-}
-
-void tst_qmlengine::offlineStoragePath()
-{
- // Without these set, QDesktopServices::storageLocation returns
- // strings with extra "//" at the end. We set them to ignore this problem.
- qApp->setApplicationName("tst_qmlengine");
- qApp->setOrganizationName("Nokia");
- qApp->setOrganizationDomain("nokia.com");
-
- QmlEngine engine;
-
- QDir dir(QDesktopServices::storageLocation(QDesktopServices::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_qmlengine::clearComponentCache()
-{
- QmlEngine engine;
-
- // Create original qml file
- {
- QFile file("temp.qml");
- QVERIFY(file.open(QIODevice::WriteOnly));
- file.write("import Qt 4.6\nQtObject {\nproperty int test: 10\n}\n");
- file.close();
- }
-
- // Test "test" property
- {
- QmlComponent 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 Qt 4.6\nQtObject {\nproperty int test: 11\n}\n");
- file.close();
- }
-
- // Test cache hit
- {
- QmlComponent 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
- {
- QmlComponent component(&engine, "temp.qml");
- QObject *obj = component.create();
- QVERIFY(obj != 0);
- QCOMPARE(obj->property("test").toInt(), 11);
- delete obj;
- }
-}
-
-QTEST_MAIN(tst_qmlengine)
-
-#include "tst_qmlengine.moc"
diff --git a/tests/auto/declarative/qmlerror/qmlerror.pro b/tests/auto/declarative/qmlerror/qmlerror.pro
deleted file mode 100644
index fa9b79e..0000000
--- a/tests/auto/declarative/qmlerror/qmlerror.pro
+++ /dev/null
@@ -1,6 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative
-SOURCES += tst_qmlerror.cpp
-macx:CONFIG -= app_bundle
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmlerror/tst_qmlerror.cpp b/tests/auto/declarative/qmlerror/tst_qmlerror.cpp
deleted file mode 100644
index 12dde57..0000000
--- a/tests/auto/declarative/qmlerror/tst_qmlerror.cpp
+++ /dev/null
@@ -1,242 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qtest.h>
-#include <QmlError>
-#include <QDebug>
-
-class tst_qmlerror : public QObject
-{
- Q_OBJECT
-private slots:
- void url();
- void description();
- void line();
- void column();
- void toString();
-
- void copy();
- void debug();
-};
-
-void tst_qmlerror::url()
-{
- QmlError error;
-
- QCOMPARE(error.url(), QUrl());
-
- error.setUrl(QUrl("http://www.nokia.com/main.qml"));
-
- QCOMPARE(error.url(), QUrl("http://www.nokia.com/main.qml"));
-
- QmlError 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_qmlerror::description()
-{
- QmlError error;
-
- QCOMPARE(error.description(), QString());
-
- error.setDescription("An Error");
-
- QCOMPARE(error.description(), QString("An Error"));
-
- QmlError 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_qmlerror::line()
-{
- QmlError error;
-
- QCOMPARE(error.line(), -1);
-
- error.setLine(102);
-
- QCOMPARE(error.line(), 102);
-
- QmlError error2 = error;
-
- QCOMPARE(error2.line(), 102);
-
- error.setLine(4);
-
- QCOMPARE(error.line(), 4);
- QCOMPARE(error2.line(), 102);
-}
-
-void tst_qmlerror::column()
-{
- QmlError error;
-
- QCOMPARE(error.column(), -1);
-
- error.setColumn(16);
-
- QCOMPARE(error.column(), 16);
-
- QmlError error2 = error;
-
- QCOMPARE(error2.column(), 16);
-
- error.setColumn(3);
-
- QCOMPARE(error.column(), 3);
- QCOMPARE(error2.column(), 16);
-}
-
-void tst_qmlerror::toString()
-{
- {
- QmlError 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"));
- }
-
- {
- QmlError 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_qmlerror::copy()
-{
- QmlError error;
- error.setUrl(QUrl("http://www.nokia.com/main.qml"));
- error.setDescription("An Error");
- error.setLine(92);
- error.setColumn(13);
-
- QmlError error2(error);
- QmlError 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_qmlerror::debug()
-{
- {
- QmlError 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(QUrl::fromLocalFile(QString(SRCDIR) + "/").resolved(QUrl("test.txt")));
- QmlError 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(QUrl::fromLocalFile(QString(SRCDIR) + "/").resolved(QUrl("foo.txt")));
- QmlError 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_qmlerror)
-
-#include "tst_qmlerror.moc"
diff --git a/tests/auto/declarative/qmlfontloader/qmlfontloader.pro b/tests/auto/declarative/qmlfontloader/qmlfontloader.pro
deleted file mode 100644
index bc89639..0000000
--- a/tests/auto/declarative/qmlfontloader/qmlfontloader.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative gui
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qmlfontloader.cpp
-
-# Define SRCDIR equal to test's source directory
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmlfontloader/tst_qmlfontloader.cpp b/tests/auto/declarative/qmlfontloader/tst_qmlfontloader.cpp
deleted file mode 100644
index 41b5359..0000000
--- a/tests/auto/declarative/qmlfontloader/tst_qmlfontloader.cpp
+++ /dev/null
@@ -1,156 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtDeclarative/qmlengine.h>
-#include <QtDeclarative/qmlcomponent.h>
-#include <private/qmlfontloader_p.h>
-#include "../../../shared/util.h"
-
-class tst_qmlfontloader : public QObject
-
-{
- Q_OBJECT
-public:
- tst_qmlfontloader();
-
-private slots:
- void noFont();
- void namedFont();
- void localFont();
- void failLocalFont();
- void webFont();
- void failWebFont();
-
-private slots:
-
-private:
- QmlEngine engine;
-};
-
-tst_qmlfontloader::tst_qmlfontloader()
-{
-}
-
-void tst_qmlfontloader::noFont()
-{
- QString componentStr = "import Qt 4.6\nFontLoader { }";
- QmlComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlFontLoader *fontObject = qobject_cast<QmlFontLoader*>(component.create());
-
- QVERIFY(fontObject != 0);
- QCOMPARE(fontObject->name(), QString(""));
- QCOMPARE(fontObject->source(), QUrl(""));
- QTRY_VERIFY(fontObject->status() == QmlFontLoader::Null);
-
- delete fontObject;
-}
-
-void tst_qmlfontloader::namedFont()
-{
- QString componentStr = "import Qt 4.6\nFontLoader { name: \"Helvetica\" }";
- QmlComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlFontLoader *fontObject = qobject_cast<QmlFontLoader*>(component.create());
-
- QVERIFY(fontObject != 0);
- QCOMPARE(fontObject->source(), QUrl(""));
- QCOMPARE(fontObject->name(), QString("Helvetica"));
- QTRY_VERIFY(fontObject->status() == QmlFontLoader::Ready);
-}
-
-void tst_qmlfontloader::localFont()
-{
- QString componentStr = "import Qt 4.6\nFontLoader { source: \"" SRCDIR "/data/tarzeau_ocr_a.ttf\" }";
- QmlComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlFontLoader *fontObject = qobject_cast<QmlFontLoader*>(component.create());
-
- QVERIFY(fontObject != 0);
- QVERIFY(fontObject->source() != QUrl(""));
- QTRY_COMPARE(fontObject->name(), QString("OCRA"));
- QTRY_VERIFY(fontObject->status() == QmlFontLoader::Ready);
-}
-
-void tst_qmlfontloader::failLocalFont()
-{
- QString componentStr = "import Qt 4.6\nFontLoader { source: \"" + QUrl::fromLocalFile(SRCDIR "/data/dummy.ttf").toString() + "\" }";
- QTest::ignoreMessage(QtWarningMsg, QString("Cannot load font: QUrl( \"" + QUrl::fromLocalFile(SRCDIR "/data/dummy.ttf").toString() + "\" ) ").toUtf8().constData());
- QmlComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlFontLoader *fontObject = qobject_cast<QmlFontLoader*>(component.create());
-
- QVERIFY(fontObject != 0);
- QVERIFY(fontObject->source() != QUrl(""));
- QTRY_COMPARE(fontObject->name(), QString(""));
- QTRY_VERIFY(fontObject->status() == QmlFontLoader::Error);
-}
-
-void tst_qmlfontloader::webFont()
-{
- QString componentStr = "import Qt 4.6\nFontLoader { source: \"http://www.princexml.com/fonts/steffmann/Starburst.ttf\" }";
- QmlComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlFontLoader *fontObject = qobject_cast<QmlFontLoader*>(component.create());
-
- QVERIFY(fontObject != 0);
- QVERIFY(fontObject->source() != QUrl(""));
- QTRY_COMPARE(fontObject->name(), QString("Starburst"));
- QTRY_VERIFY(fontObject->status() == QmlFontLoader::Ready);
-}
-
-void tst_qmlfontloader::failWebFont()
-{
- QString componentStr = "import Qt 4.6\nFontLoader { source: \"http://wrong.address.com/Starburst.ttf\" }";
- QTest::ignoreMessage(QtWarningMsg, "Cannot load font: QUrl( \"http://wrong.address.com/Starburst.ttf\" ) ");
- QmlComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlFontLoader *fontObject = qobject_cast<QmlFontLoader*>(component.create());
-
- QVERIFY(fontObject != 0);
- QVERIFY(fontObject->source() != QUrl(""));
- QTRY_COMPARE(fontObject->name(), QString(""));
- QTRY_VERIFY(fontObject->status() == QmlFontLoader::Error);
-}
-
-QTEST_MAIN(tst_qmlfontloader)
-
-#include "tst_qmlfontloader.moc"
diff --git a/tests/auto/declarative/qmlgraphicsanchors/qmlgraphicsanchors.pro b/tests/auto/declarative/qmlgraphicsanchors/qmlgraphicsanchors.pro
deleted file mode 100644
index 755de3f..0000000
--- a/tests/auto/declarative/qmlgraphicsanchors/qmlgraphicsanchors.pro
+++ /dev/null
@@ -1,6 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative
-SOURCES += tst_qmlgraphicsanchors.cpp
-macx:CONFIG -= app_bundle
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmlgraphicsanchors/tst_qmlgraphicsanchors.cpp b/tests/auto/declarative/qmlgraphicsanchors/tst_qmlgraphicsanchors.cpp
deleted file mode 100644
index aa6b56a..0000000
--- a/tests/auto/declarative/qmlgraphicsanchors/tst_qmlgraphicsanchors.cpp
+++ /dev/null
@@ -1,459 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QSignalSpy>
-#include <QtDeclarative/qmlengine.h>
-#include <QtDeclarative/qmlcomponent.h>
-#include <QtDeclarative/qmlview.h>
-#include <private/qmlgraphicsrectangle_p.h>
-#include <private/qmlgraphicstext_p.h>
-#include <QtDeclarative/private/qmlgraphicsanchors_p_p.h>
-
-Q_DECLARE_METATYPE(QmlGraphicsAnchors::UsedAnchor)
-Q_DECLARE_METATYPE(QmlGraphicsAnchorLine::AnchorLine)
-
-
-class tst_qmlgraphicsanchors : public QObject
-{
- Q_OBJECT
-public:
- tst_qmlgraphicsanchors() {}
-
- template<typename T>
- T *findItem(QGraphicsObject *parent, const QString &id);
-
-private slots:
- void basicAnchors();
- void loops();
- void illegalSets();
- void illegalSets_data();
- void reset();
- void reset_data();
- void resetConvenience();
- void nullItem();
- void nullItem_data();
- void crash1();
- void centerIn();
- void fill();
- void margins();
-};
-
-/*
- Find an item with the specified id.
-*/
-template<typename T>
-T *tst_qmlgraphicsanchors::findItem(QGraphicsObject *parent, const QString &objectName)
-{
- const QMetaObject &mo = T::staticMetaObject;
- QList<QGraphicsItem *> children = parent->childItems();
- for (int i = 0; i < children.count(); ++i) {
- QmlGraphicsItem *item = qobject_cast<QmlGraphicsItem *>(children.at(i)->toGraphicsObject());
- if (item) {
- if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) {
- return static_cast<T*>(item);
- }
- item = findItem<T>(item, objectName);
- if (item)
- return static_cast<T*>(item);
- }
- }
-
- return 0;
-}
-
-void tst_qmlgraphicsanchors::basicAnchors()
-{
- QmlView *view = new QmlView;
- view->setSource(QUrl::fromLocalFile(SRCDIR "/data/anchors.qml"));
-
- view->execute();
- qApp->processEvents();
-
- //sibling horizontal
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect1"))->x(), 26.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect2"))->x(), 122.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect3"))->x(), 74.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect4"))->x(), 16.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect5"))->x(), 112.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect6"))->x(), 64.0);
-
- //parent horizontal
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect7"))->x(), 0.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect8"))->x(), 240.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect9"))->x(), 120.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect10"))->x(), -10.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect11"))->x(), 230.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect12"))->x(), 110.0);
-
- //vertical
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect13"))->y(), 20.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect14"))->y(), 155.0);
-
- //stretch
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect15"))->x(), 26.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect15"))->width(), 96.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect16"))->x(), 26.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect16"))->width(), 192.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect17"))->x(), -70.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect17"))->width(), 192.0);
-
- //vertical stretch
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect18"))->y(), 20.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect18"))->height(), 40.0);
-
- //more parent horizontal
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect19"))->x(), 115.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect20"))->x(), 235.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect21"))->x(), -5.0);
-
- //centerIn
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect22"))->x(), 69.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect22"))->y(), 5.0);
-
- //margins
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect23"))->x(), 31.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect23"))->y(), 5.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect23"))->width(), 86.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect23"))->height(), 10.0);
-
- // offsets
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect24"))->x(), 26.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect25"))->y(), 60.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect26"))->y(), 5.0);
-
- //baseline
- QmlGraphicsText *text1 = findItem<QmlGraphicsText>(view->rootObject(), QLatin1String("text1"));
- QmlGraphicsText *text2 = findItem<QmlGraphicsText>(view->rootObject(), QLatin1String("text2"));
- QCOMPARE(text1->y(), text2->y());
-
- delete view;
-}
-
-// mostly testing that we don't crash
-void tst_qmlgraphicsanchors::loops()
-{
- {
- QmlView *view = new QmlView;
-
- view->setSource(QUrl::fromLocalFile(SRCDIR "/data/loop1.qml"));
-
- QString expect = "QML Text (" + view->source().toString() + ":6:5" + ") Possible anchor loop detected on horizontal anchor.";
- QTest::ignoreMessage(QtWarningMsg, expect.toLatin1());
- QTest::ignoreMessage(QtWarningMsg, expect.toLatin1());
- QTest::ignoreMessage(QtWarningMsg, expect.toLatin1());
- view->execute();
- qApp->processEvents();
-
- delete view;
- }
-
- {
- QmlView *view = new QmlView;
-
- view->setSource(QUrl::fromLocalFile(SRCDIR "/data/loop2.qml"));
-
- QString expect = "QML Image (" + view->source().toString() + ":8:3" + ") Possible anchor loop detected on horizontal anchor.";
- QTest::ignoreMessage(QtWarningMsg, expect.toLatin1());
- view->execute();
- qApp->processEvents();
-
- delete view;
- }
-}
-
-void tst_qmlgraphicsanchors::illegalSets()
-{
- QFETCH(QString, qml);
- QFETCH(QString, warning);
-
- QTest::ignoreMessage(QtWarningMsg, warning.toLatin1());
-
- QmlEngine engine;
- QmlComponent component(&engine);
- component.setData(QByteArray("import Qt 4.6\n" + qml.toUtf8()), QUrl::fromLocalFile(""));
- if (!component.isReady())
- qWarning() << "Test errors:" << component.errors();
- QVERIFY(component.isReady());
- QObject *o = component.create();
- delete o;
-}
-
-void tst_qmlgraphicsanchors::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 } }"
- << "QML Rectangle (file::2:23) 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)
- << "QML Rectangle (file::2:13) 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)
- << "QML Rectangle (file::2:45) 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)
- << "QML Rectangle (file::2:1) 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 } }"
- << "QML Rectangle (file::2:23) 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; } }"
- << "QML Text (file::2:47) 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)
- << "QML Rectangle (file::2:13) 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)
- << "QML Rectangle (file::2:45) 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)
- << "QML Rectangle (file::2:1) Cannot anchor item to self.";
- }
-
-
- QTest::newRow("centerIn - anchor to non parent/sibling")
- << "Rectangle { Item { Rectangle { id: rect } } Rectangle { anchors.centerIn: rect} }"
- << "QML Rectangle (file::2:45) 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} }"
- << "QML Rectangle (file::2:45) Cannot anchor to an item that isn't a parent or sibling.";
-}
-
-void tst_qmlgraphicsanchors::reset()
-{
- QFETCH(QString, side);
- QFETCH(QmlGraphicsAnchorLine::AnchorLine, anchorLine);
- QFETCH(QmlGraphicsAnchors::UsedAnchor, usedAnchor);
-
- QmlGraphicsItem *baseItem = new QmlGraphicsItem;
-
- QmlGraphicsAnchorLine anchor;
- anchor.item = baseItem;
- anchor.anchorLine = anchorLine;
-
- QmlGraphicsItem *item = new QmlGraphicsItem;
-
- const QMetaObject *meta = item->anchors()->metaObject();
- QMetaProperty p = meta->property(meta->indexOfProperty(side.toUtf8().constData()));
-
- QVERIFY(p.write(item->anchors(), qVariantFromValue(anchor)));
- QCOMPARE(item->anchors()->usedAnchors().testFlag(usedAnchor), true);
-
- QVERIFY(p.reset(item->anchors()));
- QCOMPARE(item->anchors()->usedAnchors().testFlag(usedAnchor), false);
-
- delete item;
- delete baseItem;
-}
-
-void tst_qmlgraphicsanchors::reset_data()
-{
- QTest::addColumn<QString>("side");
- QTest::addColumn<QmlGraphicsAnchorLine::AnchorLine>("anchorLine");
- QTest::addColumn<QmlGraphicsAnchors::UsedAnchor>("usedAnchor");
-
- QTest::newRow("left") << "left" << QmlGraphicsAnchorLine::Left << QmlGraphicsAnchors::HasLeftAnchor;
- QTest::newRow("top") << "top" << QmlGraphicsAnchorLine::Top << QmlGraphicsAnchors::HasTopAnchor;
- QTest::newRow("right") << "right" << QmlGraphicsAnchorLine::Right << QmlGraphicsAnchors::HasRightAnchor;
- QTest::newRow("bottom") << "bottom" << QmlGraphicsAnchorLine::Bottom << QmlGraphicsAnchors::HasBottomAnchor;
-
- QTest::newRow("hcenter") << "horizontalCenter" << QmlGraphicsAnchorLine::HCenter << QmlGraphicsAnchors::HasHCenterAnchor;
- QTest::newRow("vcenter") << "verticalCenter" << QmlGraphicsAnchorLine::VCenter << QmlGraphicsAnchors::HasVCenterAnchor;
- QTest::newRow("baseline") << "baseline" << QmlGraphicsAnchorLine::Baseline << QmlGraphicsAnchors::HasBaselineAnchor;
-}
-
-void tst_qmlgraphicsanchors::resetConvenience()
-{
- QmlGraphicsItem *baseItem = new QmlGraphicsItem;
- QmlGraphicsItem *item = new QmlGraphicsItem;
-
- //fill
- item->anchors()->setFill(baseItem);
- QVERIFY(item->anchors()->fill() == baseItem);
- item->anchors()->resetFill();
- QVERIFY(item->anchors()->fill() == 0);
-
- //centerIn
- item->anchors()->setCenterIn(baseItem);
- QVERIFY(item->anchors()->centerIn() == baseItem);
- item->anchors()->resetCenterIn();
- QVERIFY(item->anchors()->centerIn() == 0);
-
- delete item;
- delete baseItem;
-}
-
-void tst_qmlgraphicsanchors::nullItem()
-{
- QFETCH(QString, side);
-
- QmlGraphicsAnchorLine anchor;
- QmlGraphicsItem *item = new QmlGraphicsItem;
-
- const QMetaObject *meta = item->anchors()->metaObject();
- QMetaProperty p = meta->property(meta->indexOfProperty(side.toUtf8().constData()));
-
- QTest::ignoreMessage(QtWarningMsg, "QML Item (unknown location) Cannot anchor to a null item.");
- QVERIFY(p.write(item->anchors(), qVariantFromValue(anchor)));
-
- delete item;
-}
-
-void tst_qmlgraphicsanchors::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";
-}
-
-void tst_qmlgraphicsanchors::crash1()
-{
- QmlView *view = new QmlView;
-
- view->setSource(QUrl::fromLocalFile(SRCDIR "/data/crash1.qml"));
-
- QString expect = "QML Text (" + view->source().toString() + ":4:5" + ") Possible anchor loop detected on fill.";
- QTest::ignoreMessage(QtWarningMsg, expect.toLatin1());
- QTest::ignoreMessage(QtWarningMsg, expect.toLatin1()); // XXX ideally, should be one message
- view->execute();
- qApp->processEvents();
-
- delete view;
-}
-
-void tst_qmlgraphicsanchors::fill()
-{
- QmlView *view = new QmlView;
-
- view->setSource(QUrl::fromLocalFile(SRCDIR "/data/fill.qml"));
-
- view->execute();
- qApp->processEvents();
- QmlGraphicsRectangle* rect = findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("filler"));
- 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 (QTBUG-6631)
- rect->anchors()->setLeftMargin(20.0);
- rect->anchors()->setRightMargin(0.0);
- rect->anchors()->setBottomMargin(0.0);
- rect->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_qmlgraphicsanchors::centerIn()
-{
- QmlView *view = new QmlView;
-
- view->setSource(QUrl::fromLocalFile(SRCDIR "/data/centerin.qml"));
-
- view->execute();
- qApp->processEvents();
- QmlGraphicsRectangle* rect = findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("centered"));
- QCOMPARE(rect->x(), 75.0 + 10);
- QCOMPARE(rect->y(), 75.0 + 30);
- //Alter Offsets (QTBUG-6631)
- rect->anchors()->setHorizontalCenterOffset(-20.0);
- rect->anchors()->setVerticalCenterOffset(-10.0);
- QCOMPARE(rect->x(), 75.0 - 20.0);
- QCOMPARE(rect->y(), 75.0 - 10.0);
-
- delete view;
-}
-
-void tst_qmlgraphicsanchors::margins()
-{
- QmlView *view = new QmlView;
-
- view->setSource(QUrl::fromLocalFile(SRCDIR "/data/margins.qml"));
-
- view->execute();
- qApp->processEvents();
- QmlGraphicsRectangle* rect = findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("filler"));
- 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);
-
- rect->anchors()->setTopMargin(0.0);
- rect->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;
-}
-
-QTEST_MAIN(tst_qmlgraphicsanchors)
-
-#include "tst_qmlgraphicsanchors.moc"
diff --git a/tests/auto/declarative/qmlgraphicsanimatedimage/qmlgraphicsanimatedimage.pro b/tests/auto/declarative/qmlgraphicsanimatedimage/qmlgraphicsanimatedimage.pro
deleted file mode 100644
index 877dfab..0000000
--- a/tests/auto/declarative/qmlgraphicsanimatedimage/qmlgraphicsanimatedimage.pro
+++ /dev/null
@@ -1,7 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative network
-HEADERS += ../shared/testhttpserver.h
-SOURCES += tst_qmlgraphicsanimatedimage.cpp ../shared/testhttpserver.cpp
-macx:CONFIG -= app_bundle
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmlgraphicsanimatedimage/tst_qmlgraphicsanimatedimage.cpp b/tests/auto/declarative/qmlgraphicsanimatedimage/tst_qmlgraphicsanimatedimage.cpp
deleted file mode 100644
index 2342f25..0000000
--- a/tests/auto/declarative/qmlgraphicsanimatedimage/tst_qmlgraphicsanimatedimage.cpp
+++ /dev/null
@@ -1,191 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtDeclarative/qmlengine.h>
-#include <QtDeclarative/qmlcomponent.h>
-#include <QtDeclarative/qmlview.h>
-#include <private/qmlgraphicsrectangle_p.h>
-#include <private/qmlgraphicsimage_p.h>
-#include <private/qmlgraphicsanimatedimage_p.h>
-
-#include "../shared/testhttpserver.h"
-
-#define TRY_WAIT(expr) \
- do { \
- for (int ii = 0; ii < 6; ++ii) { \
- if ((expr)) break; \
- QTest::qWait(50); \
- } \
- QVERIFY((expr)); \
- } while (false)
-
-
-class tst_qmlgraphicsanimatedimage : public QObject
-{
- Q_OBJECT
-public:
- tst_qmlgraphicsanimatedimage() {}
-
-private slots:
- void play();
- void pause();
- void stopped();
- void setFrame();
- void frameCount();
- void remote();
- void remote_data();
- void invalidSource();
-};
-
-void tst_qmlgraphicsanimatedimage::play()
-{
- QmlEngine engine;
- QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/stickman.qml"));
- QmlGraphicsAnimatedImage *anim = qobject_cast<QmlGraphicsAnimatedImage *>(component.create());
- QVERIFY(anim);
- QVERIFY(anim->isPlaying());
-
- delete anim;
-}
-
-void tst_qmlgraphicsanimatedimage::pause()
-{
- QmlEngine engine;
- QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/stickmanpause.qml"));
- QmlGraphicsAnimatedImage *anim = qobject_cast<QmlGraphicsAnimatedImage *>(component.create());
- QVERIFY(anim);
- QVERIFY(anim->isPlaying());
- QVERIFY(anim->isPaused());
-
- delete anim;
-}
-
-void tst_qmlgraphicsanimatedimage::stopped()
-{
- QmlEngine engine;
- QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/stickmanstopped.qml"));
- QmlGraphicsAnimatedImage *anim = qobject_cast<QmlGraphicsAnimatedImage *>(component.create());
- QVERIFY(anim);
- QVERIFY(!anim->isPlaying());
- QCOMPARE(anim->currentFrame(), 0);
-
- delete anim;
-}
-
-void tst_qmlgraphicsanimatedimage::setFrame()
-{
- QmlEngine engine;
- QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/stickmanpause.qml"));
- QmlGraphicsAnimatedImage *anim = qobject_cast<QmlGraphicsAnimatedImage *>(component.create());
- QVERIFY(anim);
- QVERIFY(anim->isPlaying());
- QCOMPARE(anim->currentFrame(), 2);
-
- delete anim;
-}
-
-void tst_qmlgraphicsanimatedimage::frameCount()
-{
- QmlEngine engine;
- QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/colors.qml"));
- QmlGraphicsAnimatedImage *anim = qobject_cast<QmlGraphicsAnimatedImage *>(component.create());
- QVERIFY(anim);
- QVERIFY(anim->isPlaying());
- QCOMPARE(anim->frameCount(), 3);
-
- delete anim;
-}
-
-void tst_qmlgraphicsanimatedimage::remote()
-{
- QFETCH(QString, fileName);
- QFETCH(bool, paused);
-
- TestHTTPServer server(14445);
- QVERIFY(server.isValid());
- server.serveDirectory(SRCDIR "/data");
-
- QmlEngine engine;
- QmlComponent component(&engine, QUrl("http://127.0.0.1:14445/" + fileName));
- TRY_WAIT(component.isReady());
-
- QmlGraphicsAnimatedImage *anim = qobject_cast<QmlGraphicsAnimatedImage *>(component.create());
- QVERIFY(anim);
-
- TRY_WAIT(anim->isPlaying());
- if (paused) {
- TRY_WAIT(anim->isPaused());
- QCOMPARE(anim->currentFrame(), 2);
- }
-
- delete anim;
-}
-
-void tst_qmlgraphicsanimatedimage::remote_data()
-{
- QTest::addColumn<QString>("fileName");
- QTest::addColumn<bool>("paused");
-
- QTest::newRow("playing") << "stickman.qml" << false;
- QTest::newRow("paused") << "stickmanpause.qml" << true;
-}
-
-void tst_qmlgraphicsanimatedimage::invalidSource()
-{
- QmlEngine engine;
- QmlComponent component(&engine);
- component.setData("import Qt 4.6\n AnimatedImage { source: \"no-such-file.gif\" }", QUrl::fromLocalFile(""));
- QVERIFY(component.isReady());
-
- QTest::ignoreMessage(QtWarningMsg, "Error Reading Animated Image File QUrl( \"file:no-such-file.gif\" ) ");
-
- QmlGraphicsAnimatedImage *anim = qobject_cast<QmlGraphicsAnimatedImage *>(component.create());
- QVERIFY(anim);
-
- QVERIFY(!anim->isPlaying());
- QVERIFY(!anim->isPaused());
- QCOMPARE(anim->currentFrame(), 0);
- QCOMPARE(anim->frameCount(), 0);
-}
-
-QTEST_MAIN(tst_qmlgraphicsanimatedimage)
-
-#include "tst_qmlgraphicsanimatedimage.moc"
diff --git a/tests/auto/declarative/qmlgraphicsborderimage/qmlgraphicsborderimage.pro b/tests/auto/declarative/qmlgraphicsborderimage/qmlgraphicsborderimage.pro
deleted file mode 100644
index 1f606e5..0000000
--- a/tests/auto/declarative/qmlgraphicsborderimage/qmlgraphicsborderimage.pro
+++ /dev/null
@@ -1,9 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative gui network
-macx:CONFIG -= app_bundle
-
-HEADERS += ../shared/testhttpserver.h
-SOURCES += tst_qmlgraphicsborderimage.cpp ../shared/testhttpserver.cpp
-
-# Define SRCDIR equal to test's source directory
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmlgraphicsborderimage/tst_qmlgraphicsborderimage.cpp b/tests/auto/declarative/qmlgraphicsborderimage/tst_qmlgraphicsborderimage.cpp
deleted file mode 100644
index bb978d1..0000000
--- a/tests/auto/declarative/qmlgraphicsborderimage/tst_qmlgraphicsborderimage.cpp
+++ /dev/null
@@ -1,351 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QTextDocument>
-#include <QTcpServer>
-#include <QTcpSocket>
-#include <QDir>
-
-#include <QtDeclarative/qmlengine.h>
-#include <QtDeclarative/qmlcomponent.h>
-#include <private/qmlgraphicsborderimage_p.h>
-#include <private/qmlgraphicsimagebase_p.h>
-#include <private/qmlgraphicsscalegrid_p_p.h>
-#include <private/qmlgraphicsloader_p.h>
-#include <QtDeclarative/qmlcontext.h>
-
-#include "../shared/testhttpserver.h"
-
-
-#define SERVER_PORT 14445
-#define SERVER_ADDR "http://127.0.0.1:14445"
-
-#define TRY_WAIT(expr) \
- do { \
- for (int ii = 0; ii < 60; ++ii) { \
- if ((expr)) break; \
- QTest::qWait(50); \
- } \
- QVERIFY((expr)); \
- } while (false)
-
-
-class tst_qmlgraphicsborderimage : public QObject
-
-{
- Q_OBJECT
-public:
- tst_qmlgraphicsborderimage();
-
-private slots:
- void noSource();
- void imageSource();
- void imageSource_data();
- void clearSource();
- void resized();
- void smooth();
- void tileModes();
- void sciSource();
- void sciSource_data();
- void invalidSciFile();
- void pendingRemoteRequest();
- void pendingRemoteRequest_data();
-
-private:
- QmlEngine engine;
-};
-
-tst_qmlgraphicsborderimage::tst_qmlgraphicsborderimage()
-{
-}
-
-void tst_qmlgraphicsborderimage::noSource()
-{
- QString componentStr = "import Qt 4.6\nBorderImage { source: \"\" }";
- QmlComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsBorderImage *obj = qobject_cast<QmlGraphicsBorderImage*>(component.create());
- QVERIFY(obj != 0);
- QCOMPARE(obj->source(), QUrl());
- QCOMPARE(obj->width(), 0.);
- QCOMPARE(obj->height(), 0.);
- QCOMPARE(obj->horizontalTileMode(), QmlGraphicsBorderImage::Stretch);
- QCOMPARE(obj->verticalTileMode(), QmlGraphicsBorderImage::Stretch);
-
- delete obj;
-}
-
-void tst_qmlgraphicsborderimage::imageSource_data()
-{
- QTest::addColumn<QString>("source");
- QTest::addColumn<bool>("remote");
- QTest::addColumn<QString>("error");
-
- QTest::newRow("local") << QUrl::fromLocalFile(SRCDIR "/data/colors.png").toString() << false << "";
- QTest::newRow("local not found") << QUrl::fromLocalFile(SRCDIR "/data/no-such-file.png").toString() << false
- << "Cannot open QUrl( \"" + QUrl::fromLocalFile(SRCDIR "/data/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
- << "\"Error downloading " SERVER_ADDR "/no-such-file.png - server replied: Not found\" ";
-}
-
-void tst_qmlgraphicsborderimage::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(SRCDIR "/data");
- }
-
- if (!error.isEmpty())
- QTest::ignoreMessage(QtWarningMsg, error.toUtf8());
-
- QString componentStr = "import Qt 4.6\nBorderImage { source: \"" + source + "\" }";
- QmlComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsBorderImage *obj = qobject_cast<QmlGraphicsBorderImage*>(component.create());
- QVERIFY(obj != 0);
-
- if (remote)
- TRY_WAIT(obj->status() == QmlGraphicsBorderImage::Loading);
-
- QCOMPARE(obj->source(), remote ? source : QUrl(source));
-
- if (error.isEmpty()) {
- TRY_WAIT(obj->status() == QmlGraphicsBorderImage::Ready);
- QCOMPARE(obj->width(), 120.);
- QCOMPARE(obj->height(), 120.);
- QCOMPARE(obj->horizontalTileMode(), QmlGraphicsBorderImage::Stretch);
- QCOMPARE(obj->verticalTileMode(), QmlGraphicsBorderImage::Stretch);
- } else {
- TRY_WAIT(obj->status() == QmlGraphicsBorderImage::Error);
- }
-
- delete obj;
- delete server;
-}
-
-void tst_qmlgraphicsborderimage::clearSource()
-{
- QString componentStr = "import Qt 4.6\nBorderImage { source: srcImage }";
- QmlContext *ctxt = engine.rootContext();
- ctxt->setContextProperty("srcImage", QUrl::fromLocalFile(SRCDIR "/data/colors.png"));
- QmlComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsBorderImage *obj = qobject_cast<QmlGraphicsBorderImage*>(component.create());
- QVERIFY(obj != 0);
- QVERIFY(obj->status() == QmlGraphicsBorderImage::Ready);
- QCOMPARE(obj->width(), 120.);
- QCOMPARE(obj->height(), 120.);
-
- ctxt->setContextProperty("srcImage", "");
- QVERIFY(obj->source().isEmpty());
- QVERIFY(obj->status() == QmlGraphicsBorderImage::Null);
- QCOMPARE(obj->width(), 0.);
- QCOMPARE(obj->height(), 0.);
-}
-
-void tst_qmlgraphicsborderimage::resized()
-{
- QString componentStr = "import Qt 4.6\nBorderImage { source: \"" + QUrl::fromLocalFile(SRCDIR "/data/colors.png").toString() + "\"; width: 300; height: 300 }";
- QmlComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsBorderImage *obj = qobject_cast<QmlGraphicsBorderImage*>(component.create());
- QVERIFY(obj != 0);
- QCOMPARE(obj->width(), 300.);
- QCOMPARE(obj->height(), 300.);
- QCOMPARE(obj->horizontalTileMode(), QmlGraphicsBorderImage::Stretch);
- QCOMPARE(obj->verticalTileMode(), QmlGraphicsBorderImage::Stretch);
-
- delete obj;
-}
-
-void tst_qmlgraphicsborderimage::smooth()
-{
- QString componentStr = "import Qt 4.6\nBorderImage { source: \"" SRCDIR "/data/colors.png\"; smooth: true; width: 300; height: 300 }";
- QmlComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsBorderImage *obj = qobject_cast<QmlGraphicsBorderImage*>(component.create());
- QVERIFY(obj != 0);
- QCOMPARE(obj->width(), 300.);
- QCOMPARE(obj->height(), 300.);
- QCOMPARE(obj->smooth(), true);
- QCOMPARE(obj->horizontalTileMode(), QmlGraphicsBorderImage::Stretch);
- QCOMPARE(obj->verticalTileMode(), QmlGraphicsBorderImage::Stretch);
-
- delete obj;
-}
-
-void tst_qmlgraphicsborderimage::tileModes()
-{
- {
- QString componentStr = "import Qt 4.6\nBorderImage { source: \"" SRCDIR "/data/colors.png\"; width: 100; height: 300; horizontalTileMode: BorderImage.Repeat; verticalTileMode: BorderImage.Repeat }";
- QmlComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsBorderImage *obj = qobject_cast<QmlGraphicsBorderImage*>(component.create());
- QVERIFY(obj != 0);
- QCOMPARE(obj->width(), 100.);
- QCOMPARE(obj->height(), 300.);
- QCOMPARE(obj->horizontalTileMode(), QmlGraphicsBorderImage::Repeat);
- QCOMPARE(obj->verticalTileMode(), QmlGraphicsBorderImage::Repeat);
-
- delete obj;
- }
- {
- QString componentStr = "import Qt 4.6\nBorderImage { source: \"" SRCDIR "/data/colors.png\"; width: 300; height: 150; horizontalTileMode: BorderImage.Round; verticalTileMode: BorderImage.Round }";
- QmlComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsBorderImage *obj = qobject_cast<QmlGraphicsBorderImage*>(component.create());
- QVERIFY(obj != 0);
- QCOMPARE(obj->width(), 300.);
- QCOMPARE(obj->height(), 150.);
- QCOMPARE(obj->horizontalTileMode(), QmlGraphicsBorderImage::Round);
- QCOMPARE(obj->verticalTileMode(), QmlGraphicsBorderImage::Round);
-
- delete obj;
- }
-}
-
-void tst_qmlgraphicsborderimage::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(SRCDIR "/data");
- }
-
- QString componentStr = "import Qt 4.6\nBorderImage { source: \"" + source + "\"; width: 300; height: 300 }";
- QmlComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsBorderImage *obj = qobject_cast<QmlGraphicsBorderImage*>(component.create());
- QVERIFY(obj != 0);
-
- if (remote)
- TRY_WAIT(obj->status() == QmlGraphicsBorderImage::Loading);
-
- QCOMPARE(obj->source(), remote ? source : QUrl(source));
- QCOMPARE(obj->width(), 300.);
- QCOMPARE(obj->height(), 300.);
-
- if (valid) {
- TRY_WAIT(obj->status() == QmlGraphicsBorderImage::Ready);
- QCOMPARE(obj->border()->left(), 10);
- QCOMPARE(obj->border()->top(), 20);
- QCOMPARE(obj->border()->right(), 30);
- QCOMPARE(obj->border()->bottom(), 40);
- QCOMPARE(obj->horizontalTileMode(), QmlGraphicsBorderImage::Round);
- QCOMPARE(obj->verticalTileMode(), QmlGraphicsBorderImage::Repeat);
- } else {
- TRY_WAIT(obj->status() == QmlGraphicsBorderImage::Error);
- }
-
- delete obj;
- delete server;
-}
-
-void tst_qmlgraphicsborderimage::sciSource_data()
-{
- QTest::addColumn<QString>("source");
- QTest::addColumn<bool>("valid");
-
- QTest::newRow("local") << QUrl::fromLocalFile(SRCDIR "/data/colors-round.sci").toString() << true;
- QTest::newRow("local not found") << QUrl::fromLocalFile(SRCDIR "/data/no-such-file.sci").toString() << false;
- QTest::newRow("remote") << SERVER_ADDR "/colors-round.sci" << true;
- QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.sci" << false;
-}
-
-void tst_qmlgraphicsborderimage::invalidSciFile()
-{
- QTest::ignoreMessage(QtWarningMsg, "Unknown tile rule specified. Using Stretch "); // for "Roun"
- QTest::ignoreMessage(QtWarningMsg, "Unknown tile rule specified. Using Stretch "); // for "Repea"
-
- QString componentStr = "import Qt 4.6\nBorderImage { source: \"" + QUrl::fromLocalFile(SRCDIR "/data/invalid.sci").toString() +"\"; width: 300; height: 300 }";
- QmlComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsBorderImage *obj = qobject_cast<QmlGraphicsBorderImage*>(component.create());
- QVERIFY(obj != 0);
- QCOMPARE(obj->width(), 300.);
- QCOMPARE(obj->height(), 300.);
- QCOMPARE(obj->status(), QmlGraphicsImageBase::Error);
- QCOMPARE(obj->horizontalTileMode(), QmlGraphicsBorderImage::Stretch);
- QCOMPARE(obj->verticalTileMode(), QmlGraphicsBorderImage::Stretch);
-
- delete obj;
-}
-
-void tst_qmlgraphicsborderimage::pendingRemoteRequest()
-{
- QFETCH(QString, source);
-
- QString componentStr = "import Qt 4.6\nBorderImage { source: \"" + source + "\" }";
- QmlComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsBorderImage *obj = qobject_cast<QmlGraphicsBorderImage*>(component.create());
- QVERIFY(obj != 0);
- QCOMPARE(obj->status(), QmlGraphicsBorderImage::Loading);
-
- // verify no crash
- // This will cause a delayed "QThread: Destroyed while thread is still running" warning
- delete obj;
- QTest::qWait(50);
-}
-
-void tst_qmlgraphicsborderimage::pendingRemoteRequest_data()
-{
- QTest::addColumn<QString>("source");
-
- QTest::newRow("png file") << "http://no-such-qt-server-like-this/none.png";
- QTest::newRow("sci file") << "http://no-such-qt-server-like-this/none.sci";
-}
-
-QTEST_MAIN(tst_qmlgraphicsborderimage)
-
-#include "tst_qmlgraphicsborderimage.moc"
diff --git a/tests/auto/declarative/qmlgraphicsflickable/data/flickable02.qml b/tests/auto/declarative/qmlgraphicsflickable/data/flickable02.qml
deleted file mode 100644
index 3e08359..0000000
--- a/tests/auto/declarative/qmlgraphicsflickable/data/flickable02.qml
+++ /dev/null
@@ -1,14 +0,0 @@
-import Qt 4.6
-
-Flickable {
- width: 100; height: 100
- viewportWidth: row.width; viewportHeight: row.height
-
- Row {
- id: row
- Repeater {
- model: 4
- Rectangle { width: 200; height: 300; color: "blue" }
- }
- }
-}
diff --git a/tests/auto/declarative/qmlgraphicsflickable/data/flickable03.qml b/tests/auto/declarative/qmlgraphicsflickable/data/flickable03.qml
deleted file mode 100644
index 3ed173d..0000000
--- a/tests/auto/declarative/qmlgraphicsflickable/data/flickable03.qml
+++ /dev/null
@@ -1,14 +0,0 @@
-import Qt 4.6
-
-Flickable {
- width: 100; height: 100
- viewportWidth: column.width; viewportHeight: column.height
-
- Column {
- id: column
- Repeater {
- model: 4
- Rectangle { width: 200; height: 300; color: "blue" }
- }
- }
-}
diff --git a/tests/auto/declarative/qmlgraphicsflickable/data/flickable04.qml b/tests/auto/declarative/qmlgraphicsflickable/data/flickable04.qml
deleted file mode 100644
index 1425d85..0000000
--- a/tests/auto/declarative/qmlgraphicsflickable/data/flickable04.qml
+++ /dev/null
@@ -1,16 +0,0 @@
-import Qt 4.6
-
-Flickable {
- width: 100; height: 100
- viewportWidth: column.width; viewportHeight: column.height
- pressDelay: 200; overShoot: false; interactive: false
- maximumFlickVelocity: 2000
-
- Column {
- id: column
- Repeater {
- model: 4
- Rectangle { width: 200; height: 300; color: "blue" }
- }
- }
-}
diff --git a/tests/auto/declarative/qmlgraphicsflickable/qmlgraphicsflickable.pro b/tests/auto/declarative/qmlgraphicsflickable/qmlgraphicsflickable.pro
deleted file mode 100644
index 7c4c959..0000000
--- a/tests/auto/declarative/qmlgraphicsflickable/qmlgraphicsflickable.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative gui
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qmlgraphicsflickable.cpp
-
-# Define SRCDIR equal to test's source directory
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmlgraphicsflickable/tst_qmlgraphicsflickable.cpp b/tests/auto/declarative/qmlgraphicsflickable/tst_qmlgraphicsflickable.cpp
deleted file mode 100644
index b503571..0000000
--- a/tests/auto/declarative/qmlgraphicsflickable/tst_qmlgraphicsflickable.cpp
+++ /dev/null
@@ -1,224 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtTest/QSignalSpy>
-#include <QtDeclarative/qmlengine.h>
-#include <QtDeclarative/qmlcomponent.h>
-#include <private/qmlgraphicsflickable_p.h>
-#include <private/qmlvaluetype_p.h>
-#include <math.h>
-
-class tst_qmlgraphicsflickable : public QObject
-{
- Q_OBJECT
-public:
- tst_qmlgraphicsflickable();
-
-private slots:
- void create();
- void horizontalViewportSize();
- void verticalViewportSize();
- void properties();
- void overShoot();
- void maximumFlickVelocity();
- void flickDeceleration();
- void pressDelay();
-
-private:
- QmlEngine engine;
-};
-
-tst_qmlgraphicsflickable::tst_qmlgraphicsflickable()
-{
-}
-
-void tst_qmlgraphicsflickable::create()
-{
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/flickable01.qml"));
- QmlGraphicsFlickable *obj = qobject_cast<QmlGraphicsFlickable*>(c.create());
-
- QVERIFY(obj != 0);
- QCOMPARE(obj->isAtXBeginning(), true);
- QCOMPARE(obj->isAtXEnd(), false);
- QCOMPARE(obj->isAtYBeginning(), true);
- QCOMPARE(obj->isAtYEnd(), false);
- QCOMPARE(obj->viewportX(), 0.);
- QCOMPARE(obj->viewportY(), 0.);
-
- QCOMPARE(obj->horizontalVelocity(), 0.);
- QCOMPARE(obj->verticalVelocity(), 0.);
- QCOMPARE(obj->reportedVelocitySmoothing(), 100.);
-
- QCOMPARE(obj->isInteractive(), true);
- QCOMPARE(obj->overShoot(), true);
- QCOMPARE(obj->pressDelay(), 0);
- QCOMPARE(obj->maximumFlickVelocity(), 2000.);
-
- delete obj;
-}
-
-void tst_qmlgraphicsflickable::horizontalViewportSize()
-{
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/flickable02.qml"));
- QmlGraphicsFlickable *obj = qobject_cast<QmlGraphicsFlickable*>(c.create());
-
- QVERIFY(obj != 0);
- QCOMPARE(obj->viewportWidth(), 800.);
- QCOMPARE(obj->viewportHeight(), 300.);
- QCOMPARE(obj->isAtXBeginning(), true);
- QCOMPARE(obj->isAtXEnd(), false);
- QCOMPARE(obj->isAtYBeginning(), true);
- QCOMPARE(obj->isAtYEnd(), false);
-
- delete obj;
-}
-
-void tst_qmlgraphicsflickable::verticalViewportSize()
-{
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/flickable03.qml"));
- QmlGraphicsFlickable *obj = qobject_cast<QmlGraphicsFlickable*>(c.create());
-
- QVERIFY(obj != 0);
- QCOMPARE(obj->viewportWidth(), 200.);
- QCOMPARE(obj->viewportHeight(), 1200.);
- QCOMPARE(obj->isAtXBeginning(), true);
- QCOMPARE(obj->isAtXEnd(), false);
- QCOMPARE(obj->isAtYBeginning(), true);
- QCOMPARE(obj->isAtYEnd(), false);
-
- delete obj;
-}
-
-void tst_qmlgraphicsflickable::properties()
-{
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/flickable04.qml"));
- QmlGraphicsFlickable *obj = qobject_cast<QmlGraphicsFlickable*>(c.create());
-
- QVERIFY(obj != 0);
- QCOMPARE(obj->isInteractive(), false);
- QCOMPARE(obj->overShoot(), false);
- QCOMPARE(obj->pressDelay(), 200);
- QCOMPARE(obj->maximumFlickVelocity(), 2000.);
-
- delete obj;
-}
-
-void tst_qmlgraphicsflickable::overShoot()
-{
- QmlComponent component(&engine);
- component.setData("import Qt 4.6; Flickable { overShoot: false; }", QUrl::fromLocalFile(""));
- QmlGraphicsFlickable *flickable = qobject_cast<QmlGraphicsFlickable*>(component.create());
- QSignalSpy spy(flickable, SIGNAL(overShootChanged()));
-
- QVERIFY(flickable);
- QVERIFY(!flickable->overShoot());
-
- flickable->setOverShoot(true);
- QVERIFY(flickable->overShoot());
- QCOMPARE(spy.count(),1);
- flickable->setOverShoot(true);
- QCOMPARE(spy.count(),1);
-
- flickable->setOverShoot(false);
- QVERIFY(!flickable->overShoot());
- QCOMPARE(spy.count(),2);
- flickable->setOverShoot(false);
- QCOMPARE(spy.count(),2);
-}
-
-void tst_qmlgraphicsflickable::maximumFlickVelocity()
-{
- QmlComponent component(&engine);
- component.setData("import Qt 4.6; Flickable { maximumFlickVelocity: 1.0; }", QUrl::fromLocalFile(""));
- QmlGraphicsFlickable *flickable = qobject_cast<QmlGraphicsFlickable*>(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_qmlgraphicsflickable::flickDeceleration()
-{
- QmlComponent component(&engine);
- component.setData("import Qt 4.6; Flickable { flickDeceleration: 1.0; }", QUrl::fromLocalFile(""));
- QmlGraphicsFlickable *flickable = qobject_cast<QmlGraphicsFlickable*>(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_qmlgraphicsflickable::pressDelay()
-{
- QmlComponent component(&engine);
- component.setData("import Qt 4.6; Flickable { pressDelay: 100; }", QUrl::fromLocalFile(""));
- QmlGraphicsFlickable *flickable = qobject_cast<QmlGraphicsFlickable*>(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);
-}
-
-QTEST_MAIN(tst_qmlgraphicsflickable)
-
-#include "tst_qmlgraphicsflickable.moc"
diff --git a/tests/auto/declarative/qmlgraphicsflipable/qmlgraphicsflipable.pro b/tests/auto/declarative/qmlgraphicsflipable/qmlgraphicsflipable.pro
deleted file mode 100644
index b046086..0000000
--- a/tests/auto/declarative/qmlgraphicsflipable/qmlgraphicsflipable.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative gui
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qmlgraphicsflipable.cpp
-
-# Define SRCDIR equal to test's source directory
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmlgraphicsflipable/tst_qmlgraphicsflipable.cpp b/tests/auto/declarative/qmlgraphicsflipable/tst_qmlgraphicsflipable.cpp
deleted file mode 100644
index 24dc2e8..0000000
--- a/tests/auto/declarative/qmlgraphicsflipable/tst_qmlgraphicsflipable.cpp
+++ /dev/null
@@ -1,113 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtDeclarative/qmlengine.h>
-#include <QtDeclarative/qmlcomponent.h>
-#include <private/qmlgraphicsflipable_p.h>
-#include <private/qmlvaluetype_p.h>
-#include <QFontMetrics>
-#include <private/qmlgraphicsrectangle_p.h>
-#include <math.h>
-
-class tst_qmlgraphicsflipable : public QObject
-{
- Q_OBJECT
-public:
- tst_qmlgraphicsflipable();
-
-private slots:
- void create();
- void checkFrontAndBack();
- void setFrontAndBack();
-
-private:
- QmlEngine engine;
-};
-
-tst_qmlgraphicsflipable::tst_qmlgraphicsflipable()
-{
-}
-
-void tst_qmlgraphicsflipable::create()
-{
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/test-flipable.qml"));
- QmlGraphicsFlipable *obj = qobject_cast<QmlGraphicsFlipable*>(c.create());
-
- QVERIFY(obj != 0);
- delete obj;
-}
-
-void tst_qmlgraphicsflipable::checkFrontAndBack()
-{
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/test-flipable.qml"));
- QmlGraphicsFlipable *obj = qobject_cast<QmlGraphicsFlipable*>(c.create());
-
- QVERIFY(obj != 0);
- QVERIFY(obj->front() != 0);
- QVERIFY(obj->back() != 0);
- delete obj;
-}
-
-void tst_qmlgraphicsflipable::setFrontAndBack()
-{
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/test-flipable.qml"));
- QmlGraphicsFlipable *obj = qobject_cast<QmlGraphicsFlipable*>(c.create());
-
- QVERIFY(obj != 0);
- QVERIFY(obj->front() != 0);
- QVERIFY(obj->back() != 0);
-
- QString message = "QML Flipable (" + c.url().toString() + ":3:1) front is a write-once property";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(message));
- obj->setFront(new QmlGraphicsRectangle());
-
- message = "QML Flipable (" + c.url().toString() + ":3:1) back is a write-once property";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(message));
- obj->setBack(new QmlGraphicsRectangle());
- delete obj;
-}
-
-QTEST_MAIN(tst_qmlgraphicsflipable)
-
-#include "tst_qmlgraphicsflipable.moc"
diff --git a/tests/auto/declarative/qmlgraphicsgridview/qmlgraphicsgridview.pro b/tests/auto/declarative/qmlgraphicsgridview/qmlgraphicsgridview.pro
deleted file mode 100644
index 8eae8ae..0000000
--- a/tests/auto/declarative/qmlgraphicsgridview/qmlgraphicsgridview.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qmlgraphicsgridview.cpp
-
-# Define SRCDIR equal to test's source directory
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmlgraphicsgridview/tst_qmlgraphicsgridview.cpp b/tests/auto/declarative/qmlgraphicsgridview/tst_qmlgraphicsgridview.cpp
deleted file mode 100644
index 2520d4a..0000000
--- a/tests/auto/declarative/qmlgraphicsgridview/tst_qmlgraphicsgridview.cpp
+++ /dev/null
@@ -1,967 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qmlengine.h>
-#include <qmlcomponent.h>
-#include <QtTest/QtTest>
-#include <private/qlistmodelinterface_p.h>
-#include <qmlview.h>
-#include <private/qmlgraphicsgridview_p.h>
-#include <private/qmlgraphicstext_p.h>
-#include <qmlcontext.h>
-#include <qmlexpression.h>
-
-class tst_QmlGraphicsGridView : public QObject
-{
- Q_OBJECT
-public:
- tst_QmlGraphicsGridView();
-
-private slots:
- void items();
- void changed();
- void inserted();
- void removed();
- void moved();
- void changeFlow();
- void currentIndex();
- void defaultValues();
- void properties();
- void positionViewAtIndex();
-
-private:
- QmlView *createView(const QString &filename);
- template<typename T>
- T *findItem(QGraphicsObject *parent, const QString &id, int index=-1);
- template<typename T>
- QList<T*> findItems(QGraphicsObject *parent, const QString &objectName);
- void dumpTree(QmlGraphicsItem *parent, int depth = 0);
-};
-
-class TestModel : public QAbstractListModel
-{
-public:
- enum Roles { Name = Qt::UserRole+1, Number = Qt::UserRole+2 };
-
- TestModel(QObject *parent=0) : QAbstractListModel(parent) {
- QHash<int, QByteArray> roles;
- roles[Name] = "name";
- roles[Number] = "number";
- setRoleNames(roles);
- }
-
- int rowCount(const QModelIndex &parent=QModelIndex()) const { return list.count(); }
- QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) 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 count() const { return rowCount(); }
- QString name(int index) const { return list.at(index).first; }
- QString number(int index) const { return list.at(index).second; }
-
- void addItem(const QString &name, const QString &number) {
- emit beginInsertRows(QModelIndex(), list.count(), list.count());
- list.append(QPair<QString,QString>(name, number));
- emit endInsertRows();
- }
-
- void 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 removeItem(int index) {
- emit beginRemoveRows(QModelIndex(), index, index);
- list.removeAt(index);
- emit endRemoveRows();
- }
-
- void moveItem(int from, int to) {
- emit beginMoveRows(QModelIndex(), from, from, QModelIndex(), to);
- list.move(from, to);
- emit endMoveRows();
- }
-
- void modifyItem(int idx, const QString &name, const QString &number) {
- list[idx] = QPair<QString,QString>(name, number);
- emit dataChanged(index(idx,0), index(idx,0));
- }
-
-private:
- QList<QPair<QString,QString> > list;
-};
-
-tst_QmlGraphicsGridView::tst_QmlGraphicsGridView()
-{
-}
-
-void tst_QmlGraphicsGridView::items()
-{
- QmlView *canvas = createView(SRCDIR "/data/gridview.qml");
-
- TestModel 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");
-
- QmlContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testTopToBottom", QVariant(false));
-
- canvas->execute();
- qApp->processEvents();
-
- QmlGraphicsGridView *gridview = findItem<QmlGraphicsGridView>(canvas->rootObject(), "grid");
- QVERIFY(gridview != 0);
-
- QmlGraphicsItem *viewport = gridview->viewport();
- QVERIFY(viewport != 0);
-
- QCOMPARE(gridview->count(), model.count());
- QCOMPARE(viewport->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
-
- for (int i = 0; i < model.count(); ++i) {
- QmlGraphicsText *name = findItem<QmlGraphicsText>(viewport, "textName", i);
- QVERIFY(name != 0);
- QCOMPARE(name->text(), model.name(i));
- QmlGraphicsText *number = findItem<QmlGraphicsText>(viewport, "textNumber", i);
- QVERIFY(number != 0);
- QCOMPARE(number->text(), model.number(i));
- }
-
- // set an empty model and confirm that items are destroyed
- TestModel model2;
- ctxt->setContextProperty("testModel", &model2);
-
- int itemCount = findItems<QmlGraphicsItem>(viewport, "wrapper").count();
- QVERIFY(itemCount == 0);
-
- delete canvas;
-}
-
-void tst_QmlGraphicsGridView::changed()
-{
- QmlView *canvas = createView(SRCDIR "/data/gridview.qml");
-
- TestModel 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");
-
- QmlContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testTopToBottom", QVariant(false));
-
- canvas->execute();
- qApp->processEvents();
-
- QmlGraphicsFlickable *gridview = findItem<QmlGraphicsFlickable>(canvas->rootObject(), "grid");
- QVERIFY(gridview != 0);
-
- QmlGraphicsItem *viewport = gridview->viewport();
- QVERIFY(viewport != 0);
-
- model.modifyItem(1, "Will", "9876");
- QmlGraphicsText *name = findItem<QmlGraphicsText>(viewport, "textName", 1);
- QVERIFY(name != 0);
- QCOMPARE(name->text(), model.name(1));
- QmlGraphicsText *number = findItem<QmlGraphicsText>(viewport, "textNumber", 1);
- QVERIFY(number != 0);
- QCOMPARE(number->text(), model.number(1));
-
- delete canvas;
-}
-
-void tst_QmlGraphicsGridView::inserted()
-{
- QmlView *canvas = createView(SRCDIR "/data/gridview.qml");
-
- TestModel model;
- model.addItem("Fred", "12345");
- model.addItem("John", "2345");
- model.addItem("Bob", "54321");
-
- QmlContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testTopToBottom", QVariant(false));
-
- canvas->execute();
- qApp->processEvents();
-
- QmlGraphicsGridView *gridview = findItem<QmlGraphicsGridView>(canvas->rootObject(), "grid");
- QVERIFY(gridview != 0);
-
- QmlGraphicsItem *viewport = gridview->viewport();
- QVERIFY(viewport != 0);
-
- model.insertItem(1, "Will", "9876");
-
- // let transitions settle.
- QTest::qWait(300);
-
- QCOMPARE(viewport->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
-
- QmlGraphicsText *name = findItem<QmlGraphicsText>(viewport, "textName", 1);
- QVERIFY(name != 0);
- QCOMPARE(name->text(), model.name(1));
- QmlGraphicsText *number = findItem<QmlGraphicsText>(viewport, "textNumber", 1);
- QVERIFY(number != 0);
- QCOMPARE(number->text(), model.number(1));
-
- // Confirm items positioned correctly
- for (int i = 0; i < model.count(); ++i) {
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i);
- QCOMPARE(item->x(), (i%3)*80.0);
- QCOMPARE(item->y(), (i/3)*60.0);
- }
-
- model.insertItem(0, "Foo", "1111"); // zero index, and current item
-
- // let transitions settle.
- QTest::qWait(300);
-
- QCOMPARE(viewport->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
-
- name = findItem<QmlGraphicsText>(viewport, "textName", 0);
- QVERIFY(name != 0);
- QCOMPARE(name->text(), model.name(0));
- number = findItem<QmlGraphicsText>(viewport, "textNumber", 0);
- QVERIFY(number != 0);
- QCOMPARE(number->text(), model.number(0));
-
- QCOMPARE(gridview->currentIndex(), 1);
-
- // Confirm items positioned correctly
- for (int i = 0; i < model.count(); ++i) {
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i);
- QVERIFY(item->x() == (i%3)*80);
- QVERIFY(item->y() == (i/3)*60);
- }
-
- for (int i = model.count(); i < 30; ++i)
- model.insertItem(i, "Hello", QString::number(i));
- QTest::qWait(300);
-
- gridview->setViewportY(120);
- QTest::qWait(300);
-
- // Insert item outside visible area
- model.insertItem(1, "Hello", "1324");
- QTest::qWait(300);
-
- QVERIFY(gridview->viewportY() == 120);
-
- delete canvas;
-}
-
-void tst_QmlGraphicsGridView::removed()
-{
- QmlView *canvas = createView(SRCDIR "/data/gridview.qml");
-
- TestModel model;
- for (int i = 0; i < 40; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QmlContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testTopToBottom", QVariant(false));
-
- canvas->execute();
- qApp->processEvents();
-
- QmlGraphicsGridView *gridview = findItem<QmlGraphicsGridView>(canvas->rootObject(), "grid");
- QVERIFY(gridview != 0);
-
- QmlGraphicsItem *viewport = gridview->viewport();
- QVERIFY(viewport != 0);
-
- model.removeItem(1);
-
- // let transitions settle.
- QTest::qWait(300);
-
- QmlGraphicsText *name = findItem<QmlGraphicsText>(viewport, "textName", 1);
- QVERIFY(name != 0);
- QCOMPARE(name->text(), model.name(1));
- QmlGraphicsText *number = findItem<QmlGraphicsText>(viewport, "textNumber", 1);
- QVERIFY(number != 0);
- QCOMPARE(number->text(), model.number(1));
-
- // Confirm items positioned correctly
- int itemCount = findItems<QmlGraphicsItem>(viewport, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QVERIFY(item->x() == (i%3)*80);
- QVERIFY(item->y() == (i/3)*60);
- }
-
- // Remove first item (which is the current item);
- model.removeItem(0);
-
- // let transitions settle.
- QTest::qWait(300);
-
- name = findItem<QmlGraphicsText>(viewport, "textName", 0);
- QVERIFY(name != 0);
- QCOMPARE(name->text(), model.name(0));
- number = findItem<QmlGraphicsText>(viewport, "textNumber", 0);
- QVERIFY(number != 0);
- QCOMPARE(number->text(), model.number(0));
-
- // Confirm items positioned correctly
- itemCount = findItems<QmlGraphicsItem>(viewport, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QVERIFY(item->x() == (i%3)*80);
- QVERIFY(item->y() == (i/3)*60);
- }
-
- // Remove items not visible
- model.removeItem(25);
- // let transitions settle.
- QTest::qWait(300);
-
- // Confirm items positioned correctly
- itemCount = findItems<QmlGraphicsItem>(viewport, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QVERIFY(item->x() == (i%3)*80);
- QVERIFY(item->y() == (i/3)*60);
- }
-
- // Remove items before visible
- gridview->setViewportY(120);
- QTest::qWait(500);
- gridview->setCurrentIndex(10);
-
- // let transitions settle.
- QTest::qWait(300);
-
- // Setting currentIndex above shouldn't cause view to scroll
- QCOMPARE(gridview->viewportY(), 120.0);
-
- model.removeItem(1);
-
- // let transitions settle.
- QTest::qWait(300);
-
- // Confirm items positioned correctly
- for (int i = 6; i < 18; ++i) {
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QVERIFY(item->x() == (i%3)*80);
- QVERIFY(item->y() == (i/3)*60);
- }
-
- // Remove currentIndex
- QmlGraphicsItem *oldCurrent = gridview->currentItem();
- model.removeItem(9);
- QTest::qWait(500);
-
- QCOMPARE(gridview->currentIndex(), 9);
- QVERIFY(gridview->currentItem() != oldCurrent);
-
- gridview->setViewportY(0);
- // let transitions settle.
- QTest::qWait(300);
-
- // Confirm items positioned correctly
- itemCount = findItems<QmlGraphicsItem>(viewport, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QVERIFY(item->x() == (i%3)*80);
- QVERIFY(item->y() == (i/3)*60);
- }
-
- // remove item outside current view.
- gridview->setCurrentIndex(32);
- QTest::qWait(500);
- gridview->setViewportY(240);
-
- model.removeItem(30);
- QVERIFY(gridview->currentIndex() == 31);
-
- // remove current item beyond visible items.
- gridview->setCurrentIndex(20);
- QTest::qWait(500);
- gridview->setViewportY(0);
- model.removeItem(20);
- QTest::qWait(500);
-
- QCOMPARE(gridview->currentIndex(), 20);
- QVERIFY(gridview->currentItem() != 0);
-
- // remove item before current, but visible
- gridview->setCurrentIndex(8);
- QTest::qWait(500);
- gridview->setViewportY(240);
- oldCurrent = gridview->currentItem();
- model.removeItem(6);
- QTest::qWait(500);
-
- QCOMPARE(gridview->currentIndex(), 7);
- QVERIFY(gridview->currentItem() == oldCurrent);
-
- delete canvas;
-}
-
-void tst_QmlGraphicsGridView::moved()
-{
- QmlView *canvas = createView(SRCDIR "/data/gridview.qml");
-
- TestModel model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QmlContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testTopToBottom", QVariant(false));
-
- canvas->execute();
- qApp->processEvents();
-
- QmlGraphicsGridView *gridview = findItem<QmlGraphicsGridView>(canvas->rootObject(), "grid");
- QVERIFY(gridview != 0);
-
- QmlGraphicsItem *viewport = gridview->viewport();
- QVERIFY(viewport != 0);
-
- model.moveItem(1, 8);
-
- // let transitions settle.
- QTest::qWait(300);
-
- QmlGraphicsText *name = findItem<QmlGraphicsText>(viewport, "textName", 1);
- QVERIFY(name != 0);
- QCOMPARE(name->text(), model.name(1));
- QmlGraphicsText *number = findItem<QmlGraphicsText>(viewport, "textNumber", 1);
- QVERIFY(number != 0);
- QCOMPARE(number->text(), model.number(1));
-
- name = findItem<QmlGraphicsText>(viewport, "textName", 8);
- QVERIFY(name != 0);
- QCOMPARE(name->text(), model.name(8));
- number = findItem<QmlGraphicsText>(viewport, "textNumber", 8);
- QVERIFY(number != 0);
- QCOMPARE(number->text(), model.number(8));
-
- // Confirm items positioned correctly
- int itemCount = findItems<QmlGraphicsItem>(viewport, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QVERIFY(item->x() == (i%3)*80);
- QVERIFY(item->y() == (i/3)*60);
- }
-
- gridview->setViewportY(120);
-
- // move outside visible area
- model.moveItem(1, 25);
-
- // let transitions settle.
- QTest::qWait(300);
-
- // Confirm items positioned correctly and indexes correct
- itemCount = findItems<QmlGraphicsItem>(viewport, "wrapper").count()-1;
- for (int i = 6; i < model.count()-6 && i < itemCount+6; ++i) {
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QCOMPARE(item->x(), qreal((i%3)*80));
- QCOMPARE(item->y(), qreal((i/3)*60));
- name = findItem<QmlGraphicsText>(viewport, "textName", i);
- QVERIFY(name != 0);
- QCOMPARE(name->text(), model.name(i));
- number = findItem<QmlGraphicsText>(viewport, "textNumber", i);
- QVERIFY(number != 0);
- QCOMPARE(number->text(), model.number(i));
- }
-
- // move from outside visible into visible
- model.moveItem(28, 8);
-
- // let transitions settle.
- QTest::qWait(300);
-
- // Confirm items positioned correctly and indexes correct
- for (int i = 6; i < model.count()-6 && i < itemCount+6; ++i) {
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QVERIFY(item->x() == (i%3)*80);
- QVERIFY(item->y() == (i/3)*60);
- name = findItem<QmlGraphicsText>(viewport, "textName", i);
- QVERIFY(name != 0);
- QCOMPARE(name->text(), model.name(i));
- number = findItem<QmlGraphicsText>(viewport, "textNumber", i);
- QVERIFY(number != 0);
- QCOMPARE(number->text(), model.number(i));
- }
-
- delete canvas;
-}
-
-void tst_QmlGraphicsGridView::currentIndex()
-{
- TestModel model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), QString::number(i));
-
- QmlView *canvas = new QmlView(0);
- canvas->setFixedSize(240,320);
-
- QmlContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- QString filename(SRCDIR "/data/gridview-initCurrent.qml");
- canvas->setSource(QUrl::fromLocalFile(filename));
-
- canvas->execute();
- qApp->processEvents();
-
- QmlGraphicsGridView *gridview = findItem<QmlGraphicsGridView>(canvas->rootObject(), "grid");
- QVERIFY(gridview != 0);
-
- QmlGraphicsItem *viewport = gridview->viewport();
- QVERIFY(viewport != 0);
-
- QTest::qWait(500);
-
- // current item should be third item
- QCOMPARE(gridview->currentIndex(), 5);
- QCOMPARE(gridview->currentItem(), findItem<QmlGraphicsItem>(viewport, "wrapper", 5));
- QCOMPARE(gridview->currentItem()->y(), gridview->highlightItem()->y());
-
- gridview->moveCurrentIndexRight();
- QCOMPARE(gridview->currentIndex(), 6);
- gridview->moveCurrentIndexDown();
- QCOMPARE(gridview->currentIndex(), 9);
- gridview->moveCurrentIndexUp();
- QCOMPARE(gridview->currentIndex(), 6);
- gridview->moveCurrentIndexLeft();
- QCOMPARE(gridview->currentIndex(), 5);
-
- // no wrap
- gridview->setCurrentIndex(0);
- QCOMPARE(gridview->currentIndex(), 0);
-
- gridview->moveCurrentIndexUp();
- QCOMPARE(gridview->currentIndex(), 0);
-
- gridview->moveCurrentIndexLeft();
- QCOMPARE(gridview->currentIndex(), 0);
-
- gridview->setCurrentIndex(model.count()-1);
- QTest::qWait(500);
- 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);
- QTest::qWait(500);
-
- gridview->moveCurrentIndexLeft();
- QCOMPARE(gridview->currentIndex(), model.count()-1);
-
- QTest::qWait(500);
- QCOMPARE(gridview->viewportY(), 279.0);
-
- gridview->moveCurrentIndexRight();
- QCOMPARE(gridview->currentIndex(), 0);
-
- QTest::qWait(500);
- QCOMPARE(gridview->viewportY(), 0.0);
-
- // Test keys
- qApp->setActiveWindow(canvas);
- canvas->show();
- canvas->setFocus();
- qApp->processEvents();
-
- QTest::keyClick(canvas, Qt::Key_Down);
- QCOMPARE(gridview->currentIndex(), 3);
-
- QTest::keyClick(canvas, Qt::Key_Up);
- QCOMPARE(gridview->currentIndex(), 0);
-
- gridview->setFlow(QmlGraphicsGridView::TopToBottom);
-
- 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);
-
-
- // turn off auto highlight
- gridview->setHighlightFollowsCurrentItem(false);
- QVERIFY(gridview->highlightFollowsCurrentItem() == false);
-
- QTest::qWait(500);
- QVERIFY(gridview->highlightItem());
- qreal hlPosX = gridview->highlightItem()->x();
- qreal hlPosY = gridview->highlightItem()->y();
-
- gridview->setCurrentIndex(5);
- QTest::qWait(500);
- QCOMPARE(gridview->highlightItem()->x(), hlPosX);
- QCOMPARE(gridview->highlightItem()->y(), hlPosY);
-
- delete canvas;
-}
-
-void tst_QmlGraphicsGridView::changeFlow()
-{
- QmlView *canvas = createView(SRCDIR "/data/gridview.qml");
-
- TestModel model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), QString::number(i));
-
- QmlContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testTopToBottom", QVariant(false));
-
- canvas->execute();
- qApp->processEvents();
-
- QmlGraphicsGridView *gridview = findItem<QmlGraphicsGridView>(canvas->rootObject(), "grid");
- QVERIFY(gridview != 0);
-
- QmlGraphicsItem *viewport = gridview->viewport();
- QVERIFY(viewport != 0);
-
- // Confirm items positioned correctly and indexes correct
- int itemCount = findItems<QmlGraphicsItem>(viewport, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QCOMPARE(item->x(), qreal((i%3)*80));
- QCOMPARE(item->y(), qreal((i/3)*60));
- QmlGraphicsText *name = findItem<QmlGraphicsText>(viewport, "textName", i);
- QVERIFY(name != 0);
- QCOMPARE(name->text(), model.name(i));
- QmlGraphicsText *number = findItem<QmlGraphicsText>(viewport, "textNumber", i);
- QVERIFY(number != 0);
- QCOMPARE(number->text(), model.number(i));
- }
-
- ctxt->setContextProperty("testTopToBottom", QVariant(true));
- QTest::qWait(500);
-
- // Confirm items positioned correctly and indexes correct
- itemCount = findItems<QmlGraphicsItem>(viewport, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QCOMPARE(item->x(), qreal((i/5)*80));
- QCOMPARE(item->y(), qreal((i%5)*60));
- QmlGraphicsText *name = findItem<QmlGraphicsText>(viewport, "textName", i);
- QVERIFY(name != 0);
- QCOMPARE(name->text(), model.name(i));
- QmlGraphicsText *number = findItem<QmlGraphicsText>(viewport, "textNumber", i);
- QVERIFY(number != 0);
- QCOMPARE(number->text(), model.number(i));
- }
-
- delete canvas;
-}
-
-void tst_QmlGraphicsGridView::defaultValues()
-{
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/gridview3.qml"));
- QmlGraphicsGridView *obj = qobject_cast<QmlGraphicsGridView*>(c.create());
-
- QVERIFY(obj != 0);
- QVERIFY(obj->model() == QVariant());
- QVERIFY(obj->delegate() == 0);
- QCOMPARE(obj->currentIndex(), -1);
- QVERIFY(obj->currentItem() == 0);
- QCOMPARE(obj->count(), 0);
- QVERIFY(obj->highlight() == 0);
- QVERIFY(obj->highlightItem() == 0);
- QCOMPARE(obj->highlightFollowsCurrentItem(), true);
- QVERIFY(obj->flow() == 0);
- QCOMPARE(obj->isWrapEnabled(), false);
- QCOMPARE(obj->cacheBuffer(), 0);
- QCOMPARE(obj->cellWidth(), 100); //### Should 100 be the default?
- QCOMPARE(obj->cellHeight(), 100);
- delete obj;
-}
-
-void tst_QmlGraphicsGridView::properties()
-{
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/gridview2.qml"));
- QmlGraphicsGridView *obj = qobject_cast<QmlGraphicsGridView*>(c.create());
-
- QVERIFY(obj != 0);
- QVERIFY(obj->model() != QVariant());
- QVERIFY(obj->delegate() != 0);
- QCOMPARE(obj->currentIndex(), 0);
- QVERIFY(obj->currentItem() != 0);
- QCOMPARE(obj->count(), 4);
- QVERIFY(obj->highlight() != 0);
- QVERIFY(obj->highlightItem() != 0);
- QCOMPARE(obj->highlightFollowsCurrentItem(), false);
- QVERIFY(obj->flow() == 0);
- QCOMPARE(obj->isWrapEnabled(), true);
- QCOMPARE(obj->cacheBuffer(), 200);
- QCOMPARE(obj->cellWidth(), 100);
- QCOMPARE(obj->cellHeight(), 100);
- delete obj;
-}
-
-void tst_QmlGraphicsGridView::positionViewAtIndex()
-{
- QmlView *canvas = createView(SRCDIR "/data/gridview.qml");
-
- TestModel model;
- for (int i = 0; i < 40; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QmlContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testTopToBottom", QVariant(false));
-
- canvas->execute();
- qApp->processEvents();
-
- QmlGraphicsGridView *gridview = findItem<QmlGraphicsGridView>(canvas->rootObject(), "grid");
- QVERIFY(gridview != 0);
-
- QmlGraphicsItem *viewport = gridview->viewport();
- QVERIFY(viewport != 0);
-
- // Confirm items positioned correctly
- int itemCount = findItems<QmlGraphicsItem>(viewport, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount-1; ++i) {
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QCOMPARE(item->x(), (i%3)*80.);
- QCOMPARE(item->y(), (i/3)*60.);
- }
-
- // Position on a currently visible item
- gridview->positionViewAtIndex(4);
- QCOMPARE(gridview->viewportY(), 60.);
-
- // Confirm items positioned correctly
- itemCount = findItems<QmlGraphicsItem>(viewport, "wrapper").count();
- for (int i = 3; i < model.count() && i < itemCount-3-1; ++i) {
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QCOMPARE(item->x(), (i%3)*80.);
- QCOMPARE(item->y(), (i/3)*60.);
- }
-
- // Position on an item beyond the visible items
- gridview->positionViewAtIndex(21);
- QCOMPARE(gridview->viewportY(), 420.);
-
- // Confirm items positioned correctly
- itemCount = findItems<QmlGraphicsItem>(viewport, "wrapper").count();
- for (int i = 22; i < model.count() && i < itemCount-22-1; ++i) {
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QCOMPARE(item->x(), (i%3)*80.);
- QCOMPARE(item->y(), (i/3)*60.);
- }
-
- // Position on an item that would leave empty space if positioned at the top
- gridview->positionViewAtIndex(31);
- QCOMPARE(gridview->viewportY(), 520.);
-
- // Confirm items positioned correctly
- itemCount = findItems<QmlGraphicsItem>(viewport, "wrapper").count();
- for (int i = 24; i < model.count() && i < itemCount-24-1; ++i) {
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QCOMPARE(item->x(), (i%3)*80.);
- QCOMPARE(item->y(), (i/3)*60.);
- }
-
- // Position at the beginning again
- gridview->positionViewAtIndex(0);
- QCOMPARE(gridview->viewportY(), 0.);
-
- // Confirm items positioned correctly
- itemCount = findItems<QmlGraphicsItem>(viewport, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount-1; ++i) {
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QCOMPARE(item->x(), (i%3)*80.);
- QCOMPARE(item->y(), (i/3)*60.);
- }
-
- delete canvas;
-}
-
-QmlView *tst_QmlGraphicsGridView::createView(const QString &filename)
-{
- QmlView *canvas = new QmlView(0);
- canvas->setFixedSize(240,320);
-
- canvas->setSource(QUrl::fromLocalFile(filename));
-
- return canvas;
-}
-
-/*
- 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 *tst_QmlGraphicsGridView::findItem(QGraphicsObject *parent, const QString &objectName, int index)
-{
- const QMetaObject &mo = T::staticMetaObject;
- //qDebug() << parent->childItems().count() << "children";
- for (int i = 0; i < parent->childItems().count(); ++i) {
- QmlGraphicsItem *item = qobject_cast<QmlGraphicsItem*>(parent->childItems().at(i));
- if(!item)
- continue;
- //qDebug() << "try" << item;
- if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) {
- if (index != -1) {
- QmlContext *context = QmlEngine::contextForObject(item);
- if (context) {
- if (context->contextProperty("index").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*> tst_QmlGraphicsGridView::findItems(QGraphicsObject *parent, const QString &objectName)
-{
- QList<T*> items;
- const QMetaObject &mo = T::staticMetaObject;
- //qDebug() << parent->childItems().count() << "children";
- for (int i = 0; i < parent->childItems().count(); ++i) {
- QmlGraphicsItem *item = qobject_cast<QmlGraphicsItem*>(parent->childItems().at(i));
- if(!item)
- continue;
- //qDebug() << "try" << item;
- if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) {
- items.append(static_cast<T*>(item));
- //qDebug() << " found:" << item;
- }
- items += findItems<T>(item, objectName);
- }
-
- return items;
-}
-
-void tst_QmlGraphicsGridView::dumpTree(QmlGraphicsItem *parent, int depth)
-{
- static QString padding(" ");
- for (int i = 0; i < parent->childItems().count(); ++i) {
- QmlGraphicsItem *item = qobject_cast<QmlGraphicsItem*>(parent->childItems().at(i));
- if(!item)
- continue;
- QmlContext *context = QmlEngine::contextForObject(item);
- qDebug() << padding.left(depth*2) << item << (context ? context->contextProperty("index").toInt() : -1);
- dumpTree(item, depth+1);
- }
-}
-
-
-QTEST_MAIN(tst_QmlGraphicsGridView)
-
-#include "tst_qmlgraphicsgridview.moc"
diff --git a/tests/auto/declarative/qmlgraphicsimage/qmlgraphicsimage.pro b/tests/auto/declarative/qmlgraphicsimage/qmlgraphicsimage.pro
deleted file mode 100644
index b5f7f83..0000000
--- a/tests/auto/declarative/qmlgraphicsimage/qmlgraphicsimage.pro
+++ /dev/null
@@ -1,9 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative gui network
-macx:CONFIG -= app_bundle
-
-HEADERS += ../shared/testhttpserver.h
-SOURCES += tst_qmlgraphicsimage.cpp ../shared/testhttpserver.cpp
-
-# Define SRCDIR equal to test's source directory
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmlgraphicsimage/tst_qmlgraphicsimage.cpp b/tests/auto/declarative/qmlgraphicsimage/tst_qmlgraphicsimage.cpp
deleted file mode 100644
index a25dcd2..0000000
--- a/tests/auto/declarative/qmlgraphicsimage/tst_qmlgraphicsimage.cpp
+++ /dev/null
@@ -1,247 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QTextDocument>
-#include <QTcpServer>
-#include <QTcpSocket>
-#include <QDir>
-
-#include <QtDeclarative/qmlengine.h>
-#include <QtDeclarative/qmlcomponent.h>
-#include <private/qmlgraphicsimage_p.h>
-#include <private/qmlgraphicsimagebase_p.h>
-#include <private/qmlgraphicsloader_p.h>
-#include <QtDeclarative/qmlcontext.h>
-
-#include "../shared/testhttpserver.h"
-
-
-#define SERVER_PORT 14445
-#define SERVER_ADDR "http://127.0.0.1:14445"
-
-#define TRY_WAIT(expr) \
- do { \
- for (int ii = 0; ii < 60; ++ii) { \
- if ((expr)) break; \
- QTest::qWait(50); \
- } \
- QVERIFY((expr)); \
- } while (false)
-
-
-class tst_qmlgraphicsimage : public QObject
-
-{
- Q_OBJECT
-public:
- tst_qmlgraphicsimage();
-
-private slots:
- void noSource();
- void imageSource();
- void imageSource_data();
- void clearSource();
- void resized();
- void smooth();
- void pixmap();
-
-private:
- QmlEngine engine;
-};
-
-tst_qmlgraphicsimage::tst_qmlgraphicsimage()
-{
-}
-
-void tst_qmlgraphicsimage::noSource()
-{
- QString componentStr = "import Qt 4.6\nImage { source: \"\" }";
- QmlComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsImage *obj = qobject_cast<QmlGraphicsImage*>(component.create());
- QVERIFY(obj != 0);
- QCOMPARE(obj->source(), QUrl());
- QVERIFY(obj->status() == QmlGraphicsImage::Null);
- QCOMPARE(obj->width(), 0.);
- QCOMPARE(obj->height(), 0.);
- QCOMPARE(obj->fillMode(), QmlGraphicsImage::Stretch);
- QCOMPARE(obj->progress(), 0.0);
-
- delete obj;
-}
-
-void tst_qmlgraphicsimage::imageSource_data()
-{
- QTest::addColumn<QString>("source");
- QTest::addColumn<bool>("remote");
- QTest::addColumn<QString>("error");
-
- QTest::newRow("local") << QUrl::fromLocalFile(SRCDIR "/data/colors.png").toString() << false << "";
- QTest::newRow("local not found") << QUrl::fromLocalFile(SRCDIR "/data/no-such-file.png").toString() << false
- << "Cannot open QUrl( \"" + QUrl::fromLocalFile(SRCDIR "/data/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
- << "\"Error downloading " SERVER_ADDR "/no-such-file.png - server replied: Not found\" ";
-}
-
-void tst_qmlgraphicsimage::imageSource()
-{
- QFETCH(QString, source);
- QFETCH(bool, remote);
- QFETCH(QString, error);
-
- TestHTTPServer server(SERVER_PORT);
- if (remote) {
- QVERIFY(server.isValid());
- server.serveDirectory(SRCDIR "/data");
- }
-
- if (!error.isEmpty())
- QTest::ignoreMessage(QtWarningMsg, error.toUtf8());
-
- QString componentStr = "import Qt 4.6\nImage { source: \"" + source + "\" }";
- QmlComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsImage *obj = qobject_cast<QmlGraphicsImage*>(component.create());
- QVERIFY(obj != 0);
-
- if (remote)
- TRY_WAIT(obj->status() == QmlGraphicsImage::Loading);
-
- QCOMPARE(obj->source(), remote ? source : QUrl(source));
-
- if (error.isEmpty()) {
- TRY_WAIT(obj->status() == QmlGraphicsImage::Ready);
- QCOMPARE(obj->width(), 120.);
- QCOMPARE(obj->height(), 120.);
- QCOMPARE(obj->fillMode(), QmlGraphicsImage::Stretch);
- QCOMPARE(obj->progress(), 1.0);
- } else {
- TRY_WAIT(obj->status() == QmlGraphicsImage::Error);
- }
-
- delete obj;
-}
-
-void tst_qmlgraphicsimage::clearSource()
-{
- QString componentStr = "import Qt 4.6\nImage { source: srcImage }";
- QmlContext *ctxt = engine.rootContext();
- ctxt->setContextProperty("srcImage", QUrl::fromLocalFile(SRCDIR "/data/colors.png"));
- QmlComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsImage *obj = qobject_cast<QmlGraphicsImage*>(component.create());
- QVERIFY(obj != 0);
- QVERIFY(obj->status() == QmlGraphicsImage::Ready);
- QCOMPARE(obj->width(), 120.);
- QCOMPARE(obj->height(), 120.);
- QCOMPARE(obj->progress(), 1.0);
-
- ctxt->setContextProperty("srcImage", "");
- QVERIFY(obj->source().isEmpty());
- QVERIFY(obj->status() == QmlGraphicsImage::Null);
- QCOMPARE(obj->width(), 0.);
- QCOMPARE(obj->height(), 0.);
- QCOMPARE(obj->progress(), 0.0);
-}
-
-void tst_qmlgraphicsimage::resized()
-{
- QString componentStr = "import Qt 4.6\nImage { source: \"" SRCDIR "/data/colors.png\"; width: 300; height: 300 }";
- QmlComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsImage *obj = qobject_cast<QmlGraphicsImage*>(component.create());
- QVERIFY(obj != 0);
- QCOMPARE(obj->width(), 300.);
- QCOMPARE(obj->height(), 300.);
- QCOMPARE(obj->fillMode(), QmlGraphicsImage::Stretch);
-
- delete obj;
-}
-
-void tst_qmlgraphicsimage::smooth()
-{
- QString componentStr = "import Qt 4.6\nImage { source: \"" SRCDIR "/data/colors.png\"; smooth: true; width: 300; height: 300 }";
- QmlComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsImage *obj = qobject_cast<QmlGraphicsImage*>(component.create());
- QVERIFY(obj != 0);
- QCOMPARE(obj->width(), 300.);
- QCOMPARE(obj->height(), 300.);
- QCOMPARE(obj->smooth(), true);
- QCOMPARE(obj->fillMode(), QmlGraphicsImage::Stretch);
-
- delete obj;
-}
-
-void tst_qmlgraphicsimage::pixmap()
-{
- QString componentStr = "import Qt 4.6\nImage { pixmap: testPixmap }";
-
- QPixmap pixmap;
- QmlContext *ctxt = engine.rootContext();
- ctxt->setContextProperty("testPixmap", pixmap);
-
- QmlComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
-
- QmlGraphicsImage *obj = qobject_cast<QmlGraphicsImage*>(component.create());
- QVERIFY(obj != 0);
- QCOMPARE(obj->source(), QUrl());
- QVERIFY(obj->status() == QmlGraphicsImage::Null);
- QCOMPARE(obj->width(), 0.);
- QCOMPARE(obj->height(), 0.);
- QCOMPARE(obj->fillMode(), QmlGraphicsImage::Stretch);
- QCOMPARE(obj->progress(), 0.0);
- QVERIFY(obj->pixmap().isNull());
-
- pixmap = QPixmap(SRCDIR "/data/colors.png");
- ctxt->setContextProperty("testPixmap", pixmap);
- QCOMPARE(obj->width(), 120.);
- QCOMPARE(obj->height(), 120.);
- QVERIFY(obj->status() == QmlGraphicsImage::Ready);
-
- delete obj;
-}
-
-QTEST_MAIN(tst_qmlgraphicsimage)
-
-#include "tst_qmlgraphicsimage.moc"
diff --git a/tests/auto/declarative/qmlgraphicsitem/qmlgraphicsitem.pro b/tests/auto/declarative/qmlgraphicsitem/qmlgraphicsitem.pro
deleted file mode 100644
index ddabf9a..0000000
--- a/tests/auto/declarative/qmlgraphicsitem/qmlgraphicsitem.pro
+++ /dev/null
@@ -1,7 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative gui
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qmlgraphicsitem.cpp
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmlgraphicsitem/tst_qmlgraphicsitem.cpp b/tests/auto/declarative/qmlgraphicsitem/tst_qmlgraphicsitem.cpp
deleted file mode 100644
index 820a6de..0000000
--- a/tests/auto/declarative/qmlgraphicsitem/tst_qmlgraphicsitem.cpp
+++ /dev/null
@@ -1,321 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtTest/QSignalSpy>
-#include <QtDeclarative/qmlengine.h>
-#include <QtDeclarative/qmlcomponent.h>
-#include <QtDeclarative/qmlcontext.h>
-#include <QtDeclarative/qmlview.h>
-#include <QtDeclarative/qmlgraphicsitem.h>
-
-class tst_QmlGraphicsItem : public QObject
-
-{
- Q_OBJECT
-public:
- tst_QmlGraphicsItem();
-
-private slots:
- void keys();
- void keyNavigation();
- void smooth();
- void clip();
-
-private:
- template<typename T>
- T *findItem(QGraphicsObject *parent, const QString &objectName);
- QmlEngine engine;
-};
-
-class KeysTestObject : public QObject
-{
- Q_OBJECT
-public:
- KeysTestObject() : mKey(0), mModifiers(0), mForwardedKey(0) {}
-
- void reset() {
- mKey = 0;
- mText = QString();
- mModifiers = 0;
- mForwardedKey = 0;
- }
-
-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;
- }
-
-public:
- int mKey;
- QString mText;
- int mModifiers;
- int mForwardedKey;
-
-private:
-};
-
-
-tst_QmlGraphicsItem::tst_QmlGraphicsItem()
-{
-}
-
-void tst_QmlGraphicsItem::keys()
-{
- QmlView *canvas = new QmlView(0);
- canvas->setFixedSize(240,320);
-
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/keys.qml"));
-
- KeysTestObject *testObject = new KeysTestObject;
- canvas->rootContext()->setContextProperty("keysTestObject", testObject);
-
- canvas->rootContext()->setContextProperty("enableKeyHanding", QVariant(true));
-
- canvas->execute();
- canvas->show();
- qApp->processEvents();
-
- QEvent wa(QEvent::WindowActivate);
- QApplication::sendEvent(canvas, &wa);
- QFocusEvent fe(QEvent::FocusIn);
- QApplication::sendEvent(canvas, &fe);
-
- QKeyEvent key(QEvent::KeyPress, Qt::Key_A, Qt::NoModifier, "A", false, 1);
- QApplication::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);
- QApplication::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);
- QApplication::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);
- QApplication::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);
- QApplication::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();
-
- canvas->rootContext()->setContextProperty("enableKeyHanding", QVariant(false));
-
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Return, Qt::NoModifier, "", false, 1);
- QApplication::sendEvent(canvas, &key);
- QCOMPARE(testObject->mKey, 0);
- QVERIFY(!key.isAccepted());
-
- delete canvas;
- delete testObject;
-}
-
-void tst_QmlGraphicsItem::keyNavigation()
-{
- QmlView *canvas = new QmlView(0);
- canvas->setFixedSize(240,320);
-
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/keynavigation.qml"));
- canvas->execute();
- canvas->show();
- qApp->processEvents();
-
- QEvent wa(QEvent::WindowActivate);
- QApplication::sendEvent(canvas, &wa);
- QFocusEvent fe(QEvent::FocusIn);
- QApplication::sendEvent(canvas, &fe);
-
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(canvas->rootObject(), "item1");
- QVERIFY(item);
- QVERIFY(item->hasFocus());
-
- // right
- QKeyEvent key(QEvent::KeyPress, Qt::Key_Right, Qt::NoModifier, "", false, 1);
- QApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
-
- item = findItem<QmlGraphicsItem>(canvas->rootObject(), "item2");
- QVERIFY(item);
- QVERIFY(item->hasFocus());
-
- // down
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Down, Qt::NoModifier, "", false, 1);
- QApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
-
- item = findItem<QmlGraphicsItem>(canvas->rootObject(), "item4");
- QVERIFY(item);
- QVERIFY(item->hasFocus());
-
- // left
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Left, Qt::NoModifier, "", false, 1);
- QApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
-
- item = findItem<QmlGraphicsItem>(canvas->rootObject(), "item3");
- QVERIFY(item);
- QVERIFY(item->hasFocus());
-
- // up
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Up, Qt::NoModifier, "", false, 1);
- QApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
-
- item = findItem<QmlGraphicsItem>(canvas->rootObject(), "item1");
- QVERIFY(item);
- QVERIFY(item->hasFocus());
-}
-
-void tst_QmlGraphicsItem::smooth()
-{
- QmlComponent component(&engine);
- component.setData("import Qt 4.6; Item { smooth: false; }", QUrl::fromLocalFile(""));
- QmlGraphicsItem *item = qobject_cast<QmlGraphicsItem*>(component.create());
- QSignalSpy spy(item, SIGNAL(smoothChanged()));
-
- QVERIFY(item);
- QVERIFY(!item->smooth());
-
- item->setSmooth(true);
- QVERIFY(item->smooth());
- QCOMPARE(spy.count(),1);
- item->setSmooth(true);
- QCOMPARE(spy.count(),1);
-
- item->setSmooth(false);
- QVERIFY(!item->smooth());
- QCOMPARE(spy.count(),2);
- item->setSmooth(false);
- QCOMPARE(spy.count(),2);
-}
-
-void tst_QmlGraphicsItem::clip()
-{
- QmlComponent component(&engine);
- component.setData("import Qt 4.6\nItem { clip: false\n }", QUrl::fromLocalFile(""));
- QmlGraphicsItem *item = qobject_cast<QmlGraphicsItem*>(component.create());
- QSignalSpy spy(item, SIGNAL(clipChanged()));
-
- QVERIFY(item);
- QVERIFY(!item->clip());
-
- item->setClip(true);
- QVERIFY(item->clip());
- 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);
-}
-
-template<typename T>
-T *tst_QmlGraphicsItem::findItem(QGraphicsObject *parent, const QString &objectName)
-{
- if (!parent)
- return 0;
-
- const QMetaObject &mo = T::staticMetaObject;
- //qDebug() << parent->QGraphicsObject::children().count() << "children";
- for (int i = 0; i < parent->childItems().count(); ++i) {
- QmlGraphicsItem *item = qobject_cast<QmlGraphicsItem*>(parent->childItems().at(i));
- if(!item)
- continue;
- //qDebug() << "try" << item;
- if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName))
- return static_cast<T*>(item);
- item = findItem<T>(item, objectName);
- if (item)
- return static_cast<T*>(item);
- }
-
- return 0;
-}
-
-
-
-QTEST_MAIN(tst_QmlGraphicsItem)
-
-#include "tst_qmlgraphicsitem.moc"
diff --git a/tests/auto/declarative/qmlgraphicslistview/data/listview.qml b/tests/auto/declarative/qmlgraphicslistview/data/listview.qml
deleted file mode 100644
index 99b3db6..0000000
--- a/tests/auto/declarative/qmlgraphicslistview/data/listview.qml
+++ /dev/null
@@ -1,119 +0,0 @@
-import Qt 4.6
-
-Rectangle {
- width: 240
- height: 320
- color: "#ffffff"
- function checkProperties() {
- testObject.error = false;
- if (list.model != testModel) {
- console.log("model property incorrect");
- testObject.error = true;
- }
- if (!testObject.animate && list.delegate != myDelegate) {
- console.log("delegate property incorrect - expected myDelegate");
- testObject.error = true;
- }
- if (testObject.animate && list.delegate != animatedDelegate) {
- console.log("delegate property incorrect - expected animatedDelegate");
- testObject.error = true;
- }
- if (testObject.invalidHighlight && list.highlight != invalidHl) {
- console.log("highlight property incorrect - expected invalidHl");
- testObject.error = true;
- }
- if (!testObject.invalidHighlight && list.highlight != myHighlight) {
- console.log("highlight property incorrect - expected myHighlight");
- testObject.error = true;
- }
- }
- resources: [
- Component {
- id: myDelegate
- Rectangle {
- id: wrapper
- objectName: "wrapper"
- height: 20
- width: 240
- Text {
- text: index
- }
- Text {
- x: 30
- id: textName
- objectName: "textName"
- text: name
- }
- Text {
- x: 120
- id: textNumber
- objectName: "textNumber"
- text: number
- }
- Text {
- x: 200
- text: wrapper.y
- }
- color: ListView.isCurrentItem ? "lightsteelblue" : "white"
- }
- },
- Component {
- id: animatedDelegate
- Rectangle {
- id: wrapper
- objectName: "wrapper"
- height: 20
- width: 240
- Text {
- text: index
- }
- Text {
- x: 30
- id: textName
- objectName: "textName"
- text: name
- }
- Text {
- x: 120
- id: textNumber
- objectName: "textNumber"
- text: number
- }
- Text {
- x: 200
- text: wrapper.y
- }
- color: ListView.isCurrentItem ? "lightsteelblue" : "white"
- ListView.onRemove: SequentialAnimation {
- ScriptAction { script: console.log("Fix PropertyAction with attached properties") }
-/*
- PropertyAction { target: wrapper; property: "ListView.delayRemove"; value: true }
- NumberAnimation { target: wrapper; property: "scale"; to: 0; duration: 250; easing: "easeInOutQuad" }
- PropertyAction { target: wrapper; property: "ListView.delayRemove"; value: false }
-*/
- }
- }
- },
- Component {
- id: myHighlight
- Rectangle { color: "green" }
- },
- Component {
- id: invalidHl
- EaseFollow {}
- }
- ]
- ListView {
- id: list
- objectName: "list"
- focus: true
- width: 240
- height: 320
- model: testModel
- delegate: testObject.animate ? animatedDelegate : myDelegate
- highlight: testObject.invalidHighlight ? invalidHl : myHighlight
- highlightMoveSpeed: 1000
- highlightResizeSpeed: 1000
- cacheBuffer: testObject.cacheBuffer
- }
-}
diff --git a/tests/auto/declarative/qmlgraphicslistview/qmlgraphicslistview.pro b/tests/auto/declarative/qmlgraphicslistview/qmlgraphicslistview.pro
deleted file mode 100644
index f00de39..0000000
--- a/tests/auto/declarative/qmlgraphicslistview/qmlgraphicslistview.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qmlgraphicslistview.cpp
-
-# Define SRCDIR equal to test's source directory
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmlgraphicslistview/tst_qmlgraphicslistview.cpp b/tests/auto/declarative/qmlgraphicslistview/tst_qmlgraphicslistview.cpp
deleted file mode 100644
index 13ed41d..0000000
--- a/tests/auto/declarative/qmlgraphicslistview/tst_qmlgraphicslistview.cpp
+++ /dev/null
@@ -1,1374 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <QtTest/QtTest>
-#include <private/qlistmodelinterface_p.h>
-#include <qmlview.h>
-#include <private/qmlgraphicslistview_p.h>
-#include <private/qmlgraphicstext_p.h>
-#include <private/qmlgraphicsvisualitemmodel_p.h>
-#include <qmlcontext.h>
-#include <qmlexpression.h>
-
-class tst_QmlGraphicsListView : public QObject
-{
- Q_OBJECT
-public:
- tst_QmlGraphicsListView();
-
-private slots:
- // Test both QListModelInterface and QAbstractItemModel model types
- void qListModelInterface_items();
- void qAbstractItemModel_items();
-
- void qListModelInterface_changed();
- void qAbstractItemModel_changed();
-
- void qListModelInterface_inserted();
- void qAbstractItemModel_inserted();
-
- void qListModelInterface_removed();
- void qAbstractItemModel_removed();
-
- void qListModelInterface_moved();
- void qAbstractItemModel_moved();
-
- void qListModelInterface_clear();
- void qAbstractItemModel_clear();
-
- void itemList();
- void currentIndex();
- void enforceRange();
- void spacing();
- void sections();
- void cacheBuffer();
- void positionViewAtIndex();
-
-private:
- template <class T> void items();
- template <class T> void changed();
- template <class T> void inserted();
- template <class T> void removed(bool animated);
- template <class T> void moved();
- template <class T> void clear();
- QmlView *createView(const QString &filename);
- template<typename T>
- T *findItem(QGraphicsObject *parent, const QString &id, int index=-1);
- template<typename T>
- QList<T*> findItems(QGraphicsObject *parent, const QString &objectName);
- void dumpTree(QmlGraphicsItem *parent, int depth = 0);
-};
-
-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;
-};
-
-class TestModel : public QListModelInterface
-{
- Q_OBJECT
-public:
- TestModel(QObject *parent = 0) : QListModelInterface(parent) {}
- ~TestModel() {}
-
- enum Roles { Name, Number };
-
- QString name(int index) const { return list.at(index).first; }
- QString number(int index) const { return list.at(index).second; }
-
- int count() const { return list.count(); }
-
- QList<int> roles() const { return QList<int>() << Name << Number; }
- QString toString(int role) const {
- switch(role) {
- case Name:
- return "name";
- case Number:
- return "number";
- default:
- return "";
- }
- }
-
- QVariant 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> 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 addItem(const QString &name, const QString &number) {
- list.append(QPair<QString,QString>(name, number));
- emit itemsInserted(list.count()-1, 1);
- }
-
- void insertItem(int index, const QString &name, const QString &number) {
- list.insert(index, QPair<QString,QString>(name, number));
- emit itemsInserted(index, 1);
- }
-
- void removeItem(int index) {
- list.removeAt(index);
- emit itemsRemoved(index, 1);
- }
-
- void moveItem(int from, int to) {
- list.move(from, to);
- emit itemsMoved(from, to, 1);
- }
-
- void modifyItem(int index, const QString &name, const QString &number) {
- list[index] = QPair<QString,QString>(name, number);
- emit itemsChanged(index, 1, roles());
- }
-
- void clear() {
- int count = list.count();
- list.clear();
- emit itemsRemoved(0, count);
- }
-
-private:
- QList<QPair<QString,QString> > list;
-};
-
-
-class TestModel2 : public QAbstractListModel
-{
-public:
- enum Roles { Name = Qt::UserRole+1, Number = Qt::UserRole+2 };
-
- TestModel2(QObject *parent=0) : QAbstractListModel(parent) {
- QHash<int, QByteArray> roles;
- roles[Name] = "name";
- roles[Number] = "number";
- setRoleNames(roles);
- }
-
- int rowCount(const QModelIndex &parent=QModelIndex()) const { return list.count(); }
- QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) 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 count() const { return rowCount(); }
- QString name(int index) const { return list.at(index).first; }
- QString number(int index) const { return list.at(index).second; }
-
- void addItem(const QString &name, const QString &number) {
- emit beginInsertRows(QModelIndex(), list.count(), list.count());
- list.append(QPair<QString,QString>(name, number));
- emit endInsertRows();
- }
-
- void 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 removeItem(int index) {
- emit beginRemoveRows(QModelIndex(), index, index);
- list.removeAt(index);
- emit endRemoveRows();
- }
-
- void moveItem(int from, int to) {
- emit beginMoveRows(QModelIndex(), from, from, QModelIndex(), to);
- list.move(from, to);
- emit endMoveRows();
- }
-
- void 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 clear() {
- int count = list.count();
- emit beginRemoveRows(QModelIndex(), 0, count-1);
- list.clear();
- emit endRemoveRows();
- }
-
-private:
- QList<QPair<QString,QString> > list;
-};
-
-tst_QmlGraphicsListView::tst_QmlGraphicsListView()
-{
-}
-
-template <class T>
-void tst_QmlGraphicsListView::items()
-{
- QmlView *canvas = createView(SRCDIR "/data/listview.qml");
-
- T model;
- model.addItem("Fred", "12345");
- model.addItem("John", "2345");
- model.addItem("Bob", "54321");
-
- QmlContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
-
- canvas->execute();
- qApp->processEvents();
-
- QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->rootObject(), "list");
- QVERIFY(listview != 0);
-
- QmlGraphicsItem *viewport = listview->viewport();
- QVERIFY(viewport != 0);
-
- QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
- QVERIFY(testObject->error() == false);
-
- QVERIFY(listview->highlightItem() != 0);
- QCOMPARE(listview->count(), model.count());
- QCOMPARE(viewport->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
-
- // current item should be first item
- QCOMPARE(listview->currentItem(), findItem<QmlGraphicsItem>(viewport, "wrapper", 0));
-
- for (int i = 0; i < model.count(); ++i) {
- QmlGraphicsText *name = findItem<QmlGraphicsText>(viewport, "textName", i);
- QVERIFY(name != 0);
- QCOMPARE(name->text(), model.name(i));
- QmlGraphicsText *number = findItem<QmlGraphicsText>(viewport, "textNumber", i);
- QVERIFY(number != 0);
- QCOMPARE(number->text(), model.number(i));
- }
-
- // switch to other delegate
- testObject->setAnimate(true);
- QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
- QVERIFY(testObject->error() == false);
- QVERIFY(listview->currentItem());
-
- // set invalid highlight
- testObject->setInvalidHighlight(true);
- QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
- QVERIFY(testObject->error() == false);
- QVERIFY(listview->currentItem());
- QVERIFY(listview->highlightItem() == 0);
-
- // back to normal highlight
- testObject->setInvalidHighlight(false);
- QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
- QVERIFY(testObject->error() == false);
- QVERIFY(listview->currentItem());
- QVERIFY(listview->highlightItem() != 0);
-
- // set an empty model and confirm that items are destroyed
- T model2;
- ctxt->setContextProperty("testModel", &model2);
-
- // Allow deleteLaters to process
- QTest::qWait(500);
-
- int itemCount = findItems<QmlGraphicsItem>(viewport, "wrapper").count();
- QVERIFY(itemCount == 0);
-
- QCOMPARE(listview->highlightResizeSpeed(), 1000.0);
- QCOMPARE(listview->highlightMoveSpeed(), 1000.0);
-
- delete canvas;
-}
-
-template <class T>
-void tst_QmlGraphicsListView::changed()
-{
- QmlView *canvas = createView(SRCDIR "/data/listview.qml");
-
- T model;
- model.addItem("Fred", "12345");
- model.addItem("John", "2345");
- model.addItem("Bob", "54321");
-
- QmlContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
-
- canvas->execute();
- qApp->processEvents();
-
- QmlGraphicsFlickable *listview = findItem<QmlGraphicsFlickable>(canvas->rootObject(), "list");
- QVERIFY(listview != 0);
-
- QmlGraphicsItem *viewport = listview->viewport();
- QVERIFY(viewport != 0);
-
- model.modifyItem(1, "Will", "9876");
- QmlGraphicsText *name = findItem<QmlGraphicsText>(viewport, "textName", 1);
- QVERIFY(name != 0);
- QCOMPARE(name->text(), model.name(1));
- QmlGraphicsText *number = findItem<QmlGraphicsText>(viewport, "textNumber", 1);
- QVERIFY(number != 0);
- QCOMPARE(number->text(), model.number(1));
-
- delete canvas;
-}
-
-template <class T>
-void tst_QmlGraphicsListView::inserted()
-{
- QmlView *canvas = createView(SRCDIR "/data/listview.qml");
-
- T model;
- model.addItem("Fred", "12345");
- model.addItem("John", "2345");
- model.addItem("Bob", "54321");
-
- QmlContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
-
- canvas->execute();
- qApp->processEvents();
-
- QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->rootObject(), "list");
- QVERIFY(listview != 0);
-
- QmlGraphicsItem *viewport = listview->viewport();
- QVERIFY(viewport != 0);
-
- model.insertItem(1, "Will", "9876");
-
- // let transitions settle.
- QTest::qWait(500);
-
- QCOMPARE(viewport->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
-
- QmlGraphicsText *name = findItem<QmlGraphicsText>(viewport, "textName", 1);
- QVERIFY(name != 0);
- QCOMPARE(name->text(), model.name(1));
- QmlGraphicsText *number = findItem<QmlGraphicsText>(viewport, "textNumber", 1);
- QVERIFY(number != 0);
- QCOMPARE(number->text(), model.number(1));
-
- // Confirm items positioned correctly
- for (int i = 0; i < model.count(); ++i) {
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i);
- QCOMPARE(item->y(), i*20.0);
- }
-
- model.insertItem(0, "Foo", "1111"); // zero index, and current item
-
- // let transitions settle.
- QTest::qWait(500);
-
- QCOMPARE(viewport->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
-
- name = findItem<QmlGraphicsText>(viewport, "textName", 0);
- QVERIFY(name != 0);
- QCOMPARE(name->text(), model.name(0));
- number = findItem<QmlGraphicsText>(viewport, "textNumber", 0);
- QVERIFY(number != 0);
- QCOMPARE(number->text(), model.number(0));
-
- QCOMPARE(listview->currentIndex(), 1);
-
- // Confirm items positioned correctly
- for (int i = 0; i < model.count(); ++i) {
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i);
- QCOMPARE(item->y(), i*20.0);
- }
-
- for (int i = model.count(); i < 30; ++i)
- model.insertItem(i, "Hello", QString::number(i));
- QTest::qWait(500);
-
- listview->setViewportY(80);
- QTest::qWait(500);
-
- // Insert item outside visible area
- model.insertItem(1, "Hello", "1324");
- QTest::qWait(500);
-
- QVERIFY(listview->viewportY() == 80);
-
- // Confirm items positioned correctly
- for (int i = 5; i < 5+15; ++i) {
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QCOMPARE(item->y(), i*20.0 - 20.0);
- }
-
-// QCOMPARE(listview->viewportHeight(), model.count() * 20.0);
-
- delete canvas;
-}
-
-template <class T>
-void tst_QmlGraphicsListView::removed(bool animated)
-{
- QmlView *canvas = createView(SRCDIR "/data/listview.qml");
-
- T model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QmlContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- TestObject *testObject = new TestObject;
- testObject->setAnimate(animated);
- ctxt->setContextProperty("testObject", testObject);
-
- canvas->execute();
- qApp->processEvents();
-
- QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->rootObject(), "list");
- QVERIFY(listview != 0);
-
- QmlGraphicsItem *viewport = listview->viewport();
- QVERIFY(viewport != 0);
-
- model.removeItem(1);
-
- // let transitions settle.
- QTest::qWait(500);
-
- QmlGraphicsText *name = findItem<QmlGraphicsText>(viewport, "textName", 1);
- QVERIFY(name != 0);
- QCOMPARE(name->text(), model.name(1));
- QmlGraphicsText *number = findItem<QmlGraphicsText>(viewport, "textNumber", 1);
- QVERIFY(number != 0);
- QCOMPARE(number->text(), model.number(1));
-
- // Confirm items positioned correctly
- int itemCount = findItems<QmlGraphicsItem>(viewport, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QVERIFY(item->y() == i*20);
- }
-
- // Remove first item (which is the current item);
- model.removeItem(0); // post: top item starts at 20
-
- // let transitions settle.
- QTest::qWait(500);
-
- name = findItem<QmlGraphicsText>(viewport, "textName", 0);
- QVERIFY(name != 0);
- QCOMPARE(name->text(), model.name(0));
- number = findItem<QmlGraphicsText>(viewport, "textNumber", 0);
- QVERIFY(number != 0);
- QCOMPARE(number->text(), model.number(0));
-
- // Confirm items positioned correctly
- itemCount = findItems<QmlGraphicsItem>(viewport, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QCOMPARE(item->y(),i*20.0 + 20.0);
- }
-
- // Remove items not visible
- model.removeItem(18);
- // let transitions settle.
- QTest::qWait(500);
-
- // Confirm items positioned correctly
- itemCount = findItems<QmlGraphicsItem>(viewport, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QCOMPARE(item->y(),i*20.0+20.0);
- }
-
- // Remove items before visible
- listview->setViewportY(80);
- listview->setCurrentIndex(10);
-
- model.removeItem(1); // post: top item will be at 40
- // let transitions settle.
- QTest::qWait(500);
-
- // Confirm items positioned correctly
- for (int i = 2; i < 18; ++i) {
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QCOMPARE(item->y(),40+i*20.0);
- }
-
- // Remove current index
- QVERIFY(listview->currentIndex() == 9);
- QmlGraphicsItem *oldCurrent = listview->currentItem();
- model.removeItem(9);
- QTest::qWait(500);
-
- QCOMPARE(listview->currentIndex(), 9);
- QVERIFY(listview->currentItem() != oldCurrent);
-
- listview->setViewportY(40); // That's the top now
- // let transitions settle.
- QTest::qWait(500);
-
- // Confirm items positioned correctly
- itemCount = findItems<QmlGraphicsItem>(viewport, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QCOMPARE(item->y(),40+i*20.0);
- }
-
- // remove current item beyond visible items.
- listview->setCurrentIndex(20);
- QTest::qWait(500);
- listview->setViewportY(40);
- model.removeItem(20);
- QTest::qWait(500);
-
- QCOMPARE(listview->currentIndex(), 20);
- QVERIFY(listview->currentItem() != 0);
-
- // remove item before current, but visible
- listview->setCurrentIndex(8);
- QTest::qWait(500);
- oldCurrent = listview->currentItem();
- model.removeItem(6);
- QTest::qWait(500);
-
- QCOMPARE(listview->currentIndex(), 7);
- QVERIFY(listview->currentItem() == oldCurrent);
-
- delete canvas;
-}
-
-template <class T>
-void tst_QmlGraphicsListView::clear()
-{
- QmlView *canvas = createView(SRCDIR "/data/listview.qml");
-
- T model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QmlContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
-
- canvas->execute();
- qApp->processEvents();
-
- QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->rootObject(), "list");
- QVERIFY(listview != 0);
-
- QmlGraphicsItem *viewport = listview->viewport();
- QVERIFY(viewport != 0);
-
- model.clear();
-
- // let transitions settle.
- QTest::qWait(500);
-
- QVERIFY(listview->count() == 0);
- QVERIFY(listview->currentItem() == 0);
- QVERIFY(listview->viewportY() == 0);
-
- delete canvas;
-}
-
-
-template <class T>
-void tst_QmlGraphicsListView::moved()
-{
- QmlView *canvas = createView(SRCDIR "/data/listview.qml");
-
- T model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QmlContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
-
- canvas->execute();
- qApp->processEvents();
-
- QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->rootObject(), "list");
- QVERIFY(listview != 0);
-
- QmlGraphicsItem *viewport = listview->viewport();
- QVERIFY(viewport != 0);
-
- model.moveItem(1, 4);
-
- // let transitions settle.
- QTest::qWait(500);
-
- QmlGraphicsText *name = findItem<QmlGraphicsText>(viewport, "textName", 1);
- QVERIFY(name != 0);
- QCOMPARE(name->text(), model.name(1));
- QmlGraphicsText *number = findItem<QmlGraphicsText>(viewport, "textNumber", 1);
- QVERIFY(number != 0);
- QCOMPARE(number->text(), model.number(1));
-
- name = findItem<QmlGraphicsText>(viewport, "textName", 4);
- QVERIFY(name != 0);
- QCOMPARE(name->text(), model.name(4));
- number = findItem<QmlGraphicsText>(viewport, "textNumber", 4);
- QVERIFY(number != 0);
- QCOMPARE(number->text(), model.number(4));
-
- // Confirm items positioned correctly
- int itemCount = findItems<QmlGraphicsItem>(viewport, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QVERIFY(item->y() == i*20);
- }
-
- listview->setViewportY(80);
-
- // move outside visible area
- model.moveItem(1, 18);
-
- // let transitions settle.
- QTest::qWait(500);
-
- // Confirm items positioned correctly and indexes correct
- for (int i = 3; i < model.count() && i < itemCount; ++i) {
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QCOMPARE(item->y(), i*20.0 + 20);
- name = findItem<QmlGraphicsText>(viewport, "textName", i);
- QVERIFY(name != 0);
- QCOMPARE(name->text(), model.name(i));
- number = findItem<QmlGraphicsText>(viewport, "textNumber", i);
- QVERIFY(number != 0);
- QCOMPARE(number->text(), model.number(i));
- }
-
- // move from outside visible into visible
- model.moveItem(20, 4);
-
- // let transitions settle.
- QTest::qWait(500);
-
- // Confirm items positioned correctly and indexes correct
- for (int i = 3; i < model.count() && i < itemCount; ++i) {
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QCOMPARE(item->y(), i*20.0 + 20);
- name = findItem<QmlGraphicsText>(viewport, "textName", i);
- QVERIFY(name != 0);
- QCOMPARE(name->text(), model.name(i));
- number = findItem<QmlGraphicsText>(viewport, "textNumber", i);
- QVERIFY(number != 0);
- QCOMPARE(number->text(), model.number(i));
- }
-
- delete canvas;
-}
-
-void tst_QmlGraphicsListView::enforceRange()
-{
- QmlView *canvas = createView(SRCDIR "/data/listview-enforcerange.qml");
-
- TestModel model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QmlContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- canvas->execute();
- qApp->processEvents();
-
- QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->rootObject(), "list");
- QVERIFY(listview != 0);
-
- QCOMPARE(listview->preferredHighlightBegin(), 100.0);
- QCOMPARE(listview->preferredHighlightEnd(), 100.0);
- QCOMPARE(listview->highlightRangeMode(), QmlGraphicsListView::StrictlyEnforceRange);
-
- QmlGraphicsItem *viewport = listview->viewport();
- QVERIFY(viewport != 0);
-
- // view should be positioned at the top of the range.
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", 0);
- QVERIFY(item);
- QCOMPARE(listview->viewportY(), -100.0);
-
- QmlGraphicsText *name = findItem<QmlGraphicsText>(viewport, "textName", 0);
- QVERIFY(name != 0);
- QCOMPARE(name->text(), model.name(0));
- QmlGraphicsText *number = findItem<QmlGraphicsText>(viewport, "textNumber", 0);
- QVERIFY(number != 0);
- QCOMPARE(number->text(), model.number(0));
-
- // Check currentIndex is updated when viewport moves
- listview->setViewportY(20);
- QTest::qWait(500);
-
- QCOMPARE(listview->currentIndex(), 6);
-
- delete canvas;
-}
-
-void tst_QmlGraphicsListView::spacing()
-{
- QmlView *canvas = createView(SRCDIR "/data/listview.qml");
-
- TestModel model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QmlContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
-
- canvas->execute();
- qApp->processEvents();
-
- QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->rootObject(), "list");
- QVERIFY(listview != 0);
-
- QmlGraphicsItem *viewport = listview->viewport();
- QVERIFY(viewport != 0);
-
- // Confirm items positioned correctly
- int itemCount = findItems<QmlGraphicsItem>(viewport, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QVERIFY(item->y() == i*20);
- }
-
- listview->setSpacing(10);
- QVERIFY(listview->spacing() == 10);
-
- // Confirm items positioned correctly
- itemCount = findItems<QmlGraphicsItem>(viewport, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QVERIFY(item->y() == i*30);
- }
-
- listview->setSpacing(0);
-
- // Confirm items positioned correctly
- itemCount = findItems<QmlGraphicsItem>(viewport, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QCOMPARE(item->y(), i*20.0);
- }
-
- delete canvas;
-}
-
-void tst_QmlGraphicsListView::sections()
-{
- QmlView *canvas = createView(SRCDIR "/data/listview-sections.qml");
-
- TestModel model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), QString::number(i/5));
-
- QmlContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- canvas->execute();
- qApp->processEvents();
-
- QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->rootObject(), "list");
- QVERIFY(listview != 0);
-
- QmlGraphicsItem *viewport = listview->viewport();
- QVERIFY(viewport != 0);
-
- // Confirm items positioned correctly
- int itemCount = findItems<QmlGraphicsItem>(viewport, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i);
- QVERIFY(item);
- QCOMPARE(item->y(), qreal(i*20 + ((i+4)/5) * 20));
- }
-
- // Remove section boundary
- model.removeItem(5);
-
- // New section header created
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", 5);
- QVERIFY(item);
- QCOMPARE(item->height(), 40.0);
-
- model.insertItem(3, "New Item", "0");
-
- // Section header moved
- item = findItem<QmlGraphicsItem>(viewport, "wrapper", 5);
- QVERIFY(item);
- QCOMPARE(item->height(), 20.0);
-
- item = findItem<QmlGraphicsItem>(viewport, "wrapper", 6);
- QVERIFY(item);
- QCOMPARE(item->height(), 40.0);
-
- // insert item which will become a section header
- model.insertItem(6, "Replace header", "1");
-
- item = findItem<QmlGraphicsItem>(viewport, "wrapper", 6);
- QVERIFY(item);
- QCOMPARE(item->height(), 40.0);
-
- item = findItem<QmlGraphicsItem>(viewport, "wrapper", 7);
- QVERIFY(item);
- QCOMPARE(item->height(), 20.0);
-
- QCOMPARE(listview->currentSection(), QString("0"));
-
- listview->setViewportY(140);
- QCOMPARE(listview->currentSection(), QString("1"));
-
- listview->setViewportY(20);
- QCOMPARE(listview->currentSection(), QString("0"));
-
- item = findItem<QmlGraphicsItem>(viewport, "wrapper", 1);
- QVERIFY(item);
- QCOMPARE(item->height(), 20.0);
-
- delete canvas;
-}
-
-void tst_QmlGraphicsListView::currentIndex()
-{
- TestModel model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), QString::number(i));
-
- QmlView *canvas = new QmlView(0);
- canvas->setFixedSize(240,320);
-
- QmlContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testWrap", QVariant(false));
-
- QString filename(SRCDIR "/data/listview-initCurrent.qml");
- canvas->setSource(QUrl::fromLocalFile(filename));
-
- canvas->execute();
- qApp->processEvents();
-
- QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->rootObject(), "list");
- QVERIFY(listview != 0);
-
- QmlGraphicsItem *viewport = listview->viewport();
- QVERIFY(viewport != 0);
-
- QTest::qWait(500);
-
- // current item should be third item
- QCOMPARE(listview->currentIndex(), 3);
- QCOMPARE(listview->currentItem(), findItem<QmlGraphicsItem>(viewport, "wrapper", 3));
- QCOMPARE(listview->highlightItem()->y(), listview->currentItem()->y());
-
- // no wrap
- listview->setCurrentIndex(0);
- QCOMPARE(listview->currentIndex(), 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);
-
- QTest::qWait(1000);
- QCOMPARE(listview->viewportY(), 279.0);
-
- listview->incrementCurrentIndex();
- QCOMPARE(listview->currentIndex(), 0);
-
- QTest::qWait(1000);
- QCOMPARE(listview->viewportY(), 0.0);
-
- // Test keys
- canvas->show();
- qApp->processEvents();
-
- QEvent wa(QEvent::WindowActivate);
- QApplication::sendEvent(canvas, &wa);
- QFocusEvent fe(QEvent::FocusIn);
- QApplication::sendEvent(canvas, &fe);
-
- QKeyEvent key(QEvent::KeyPress, Qt::Key_Down, Qt::NoModifier, "", false, 1);
- QApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
- QCOMPARE(listview->currentIndex(), 1);
-
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Up, Qt::NoModifier, "", false, 1);
- QApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
- QCOMPARE(listview->currentIndex(), 0);
-
- // turn off auto highlight
- listview->setHighlightFollowsCurrentItem(false);
- QVERIFY(listview->highlightFollowsCurrentItem() == false);
-
- QTest::qWait(500);
- QVERIFY(listview->highlightItem());
- qreal hlPos = listview->highlightItem()->y();
-
- listview->setCurrentIndex(4);
- QTest::qWait(500);
- QCOMPARE(listview->highlightItem()->y(), hlPos);
-
- delete canvas;
-}
-
-void tst_QmlGraphicsListView::itemList()
-{
- QmlView *canvas = createView(SRCDIR "/data/itemlist.qml");
-
- canvas->execute();
- qApp->processEvents();
-
- QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->rootObject(), "view");
- QVERIFY(listview != 0);
-
- QmlGraphicsItem *viewport = listview->viewport();
- QVERIFY(viewport != 0);
-
- QmlGraphicsVisualItemModel *model = canvas->rootObject()->findChild<QmlGraphicsVisualItemModel*>("itemModel");
- QVERIFY(model != 0);
-
- QVERIFY(model->count() == 3);
- QCOMPARE(listview->currentIndex(), 0);
-
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "item1");
- QVERIFY(item);
- QCOMPARE(item->x(), 0.0);
-
- QmlGraphicsText *text = findItem<QmlGraphicsText>(viewport, "text1");
- QVERIFY(text);
- QCOMPARE(text->text(), QLatin1String("index: 0"));
-
- listview->setCurrentIndex(2);
- QTest::qWait(1000);
-
- item = findItem<QmlGraphicsItem>(viewport, "item3");
- QVERIFY(item);
- QCOMPARE(item->x(), 480.0);
-
- text = findItem<QmlGraphicsText>(viewport, "text3");
- QVERIFY(text);
- QCOMPARE(text->text(), QLatin1String("index: 2"));
-
- delete canvas;
-}
-
-void tst_QmlGraphicsListView::cacheBuffer()
-{
- QmlView *canvas = createView(SRCDIR "/data/listview.qml");
-
- TestModel model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QmlContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
-
- canvas->execute();
- qApp->processEvents();
-
- QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->rootObject(), "list");
- QVERIFY(listview != 0);
-
- QmlGraphicsItem *viewport = listview->viewport();
- QVERIFY(viewport != 0);
- QVERIFY(listview->delegate() != 0);
- QVERIFY(listview->model() != 0);
- QVERIFY(listview->highlight() != 0);
-
- // Confirm items positioned correctly
- int itemCount = findItems<QmlGraphicsItem>(viewport, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QVERIFY(item->y() == i*20);
- }
-
- testObject->setCacheBuffer(400);
- QVERIFY(listview->cacheBuffer() == 400);
-
- int newItemCount = findItems<QmlGraphicsItem>(viewport, "wrapper").count();
- QVERIFY(newItemCount > itemCount);
-
- // Confirm items positioned correctly
- for (int i = 0; i < model.count() && i < newItemCount; ++i) {
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QVERIFY(item->y() == i*20);
- }
-
- delete canvas;
-}
-
-void tst_QmlGraphicsListView::positionViewAtIndex()
-{
- QmlView *canvas = createView(SRCDIR "/data/listview.qml");
-
- TestModel model;
- for (int i = 0; i < 40; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QmlContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
-
- canvas->execute();
- qApp->processEvents();
-
- QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->rootObject(), "list");
- QVERIFY(listview != 0);
-
- QmlGraphicsItem *viewport = listview->viewport();
- QVERIFY(viewport != 0);
-
- // Confirm items positioned correctly
- int itemCount = findItems<QmlGraphicsItem>(viewport, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QCOMPARE(item->y(), i*20.);
- }
-
- // Position on a currently visible item
- listview->positionViewAtIndex(3);
- QCOMPARE(listview->viewportY(), 60.);
-
- // Confirm items positioned correctly
- itemCount = findItems<QmlGraphicsItem>(viewport, "wrapper").count();
- for (int i = 3; i < model.count() && i < itemCount-3-1; ++i) {
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QCOMPARE(item->y(), i*20.);
- }
-
- // Position on an item beyond the visible items
- listview->positionViewAtIndex(22);
- QCOMPARE(listview->viewportY(), 440.);
-
- // Confirm items positioned correctly
- itemCount = findItems<QmlGraphicsItem>(viewport, "wrapper").count();
- for (int i = 22; i < model.count() && i < itemCount-22-1; ++i) {
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QCOMPARE(item->y(), i*20.);
- }
-
- // Position on an item that would leave empty space if positioned at the top
- listview->positionViewAtIndex(28);
- QCOMPARE(listview->viewportY(), 480.);
-
- // Confirm items positioned correctly
- itemCount = findItems<QmlGraphicsItem>(viewport, "wrapper").count();
- for (int i = 24; i < model.count() && i < itemCount-24-1; ++i) {
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QCOMPARE(item->y(), i*20.);
- }
-
- // Position at the beginning again
- listview->positionViewAtIndex(0);
- QCOMPARE(listview->viewportY(), 0.);
-
- // Confirm items positioned correctly
- itemCount = findItems<QmlGraphicsItem>(viewport, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount-1; ++i) {
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QCOMPARE(item->y(), i*20.);
- }
-
- delete canvas;
-}
-
-void tst_QmlGraphicsListView::qListModelInterface_items()
-{
- items<TestModel>();
-}
-
-void tst_QmlGraphicsListView::qAbstractItemModel_items()
-{
- items<TestModel2>();
-}
-
-void tst_QmlGraphicsListView::qListModelInterface_changed()
-{
- changed<TestModel>();
-}
-
-void tst_QmlGraphicsListView::qAbstractItemModel_changed()
-{
- changed<TestModel2>();
-}
-
-void tst_QmlGraphicsListView::qListModelInterface_inserted()
-{
- inserted<TestModel>();
-}
-
-void tst_QmlGraphicsListView::qAbstractItemModel_inserted()
-{
- inserted<TestModel2>();
-}
-
-void tst_QmlGraphicsListView::qListModelInterface_removed()
-{
- removed<TestModel>(false);
- removed<TestModel>(true);
-}
-
-void tst_QmlGraphicsListView::qAbstractItemModel_removed()
-{
- removed<TestModel2>(false);
- removed<TestModel2>(true);
-}
-
-void tst_QmlGraphicsListView::qListModelInterface_moved()
-{
- moved<TestModel>();
-}
-
-void tst_QmlGraphicsListView::qAbstractItemModel_moved()
-{
- moved<TestModel2>();
-}
-
-void tst_QmlGraphicsListView::qListModelInterface_clear()
-{
- clear<TestModel>();
-}
-
-void tst_QmlGraphicsListView::qAbstractItemModel_clear()
-{
- clear<TestModel2>();
-}
-
-QmlView *tst_QmlGraphicsListView::createView(const QString &filename)
-{
- QmlView *canvas = new QmlView(0);
- canvas->setFixedSize(240,320);
-
- canvas->setSource(QUrl::fromLocalFile(filename));
-
- return canvas;
-}
-
-/*
- 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 *tst_QmlGraphicsListView::findItem(QGraphicsObject *parent, const QString &objectName, int index)
-{
- const QMetaObject &mo = T::staticMetaObject;
- //qDebug() << parent->childItems().count() << "children";
- for (int i = 0; i < parent->childItems().count(); ++i) {
- QmlGraphicsItem *item = qobject_cast<QmlGraphicsItem*>(parent->childItems().at(i));
- if(!item)
- continue;
- //qDebug() << "try" << item;
- if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) {
- if (index != -1) {
- QmlExpression e(qmlContext(item), "index", item);
- e.setTrackChange(false);
- if (e.value().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*> tst_QmlGraphicsListView::findItems(QGraphicsObject *parent, const QString &objectName)
-{
- QList<T*> items;
- const QMetaObject &mo = T::staticMetaObject;
- //qDebug() << parent->childItems().count() << "children";
- for (int i = 0; i < parent->childItems().count(); ++i) {
- QmlGraphicsItem *item = qobject_cast<QmlGraphicsItem*>(parent->childItems().at(i));
- if(!item)
- continue;
- //qDebug() << "try" << item;
- if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName))
- items.append(static_cast<T*>(item));
- items += findItems<T>(item, objectName);
- }
-
- return items;
-}
-
-void tst_QmlGraphicsListView::dumpTree(QmlGraphicsItem *parent, int depth)
-{
- static QString padding(" ");
- for (int i = 0; i < parent->childItems().count(); ++i) {
- QmlGraphicsItem *item = qobject_cast<QmlGraphicsItem*>(parent->childItems().at(i));
- if(!item)
- continue;
- qDebug() << padding.left(depth*2) << item;
- dumpTree(item, depth+1);
- }
-}
-
-
-QTEST_MAIN(tst_QmlGraphicsListView)
-
-#include "tst_qmlgraphicslistview.moc"
diff --git a/tests/auto/declarative/qmlgraphicsloader/data/GraphicsWidget250x250.qml b/tests/auto/declarative/qmlgraphicsloader/data/GraphicsWidget250x250.qml
deleted file mode 100644
index 627c7df..0000000
--- a/tests/auto/declarative/qmlgraphicsloader/data/GraphicsWidget250x250.qml
+++ /dev/null
@@ -1,5 +0,0 @@
-import Qt 4.6
-
-QGraphicsWidget {
- size: "250x250"
-}
diff --git a/tests/auto/declarative/qmlgraphicsloader/qmlgraphicsloader.pro b/tests/auto/declarative/qmlgraphicsloader/qmlgraphicsloader.pro
deleted file mode 100644
index 4837075..0000000
--- a/tests/auto/declarative/qmlgraphicsloader/qmlgraphicsloader.pro
+++ /dev/null
@@ -1,11 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative gui network
-macx:CONFIG -= app_bundle
-
-INCLUDEPATH += ../shared/
-HEADERS += ../shared/testhttpserver.h
-SOURCES += tst_qmlgraphicsloader.cpp \
- ../shared/testhttpserver.cpp
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
-
diff --git a/tests/auto/declarative/qmlgraphicsloader/tst_qmlgraphicsloader.cpp b/tests/auto/declarative/qmlgraphicsloader/tst_qmlgraphicsloader.cpp
deleted file mode 100644
index 2d3d5ee..0000000
--- a/tests/auto/declarative/qmlgraphicsloader/tst_qmlgraphicsloader.cpp
+++ /dev/null
@@ -1,464 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtGui/QGraphicsWidget>
-#include <QtGui/QGraphicsScene>
-
-#include <QSignalSpy>
-#include <QtDeclarative/qmlengine.h>
-#include <QtDeclarative/qmlcomponent.h>
-#include <private/qmlgraphicsloader_p.h>
-#include "testhttpserver.h"
-
-#define SERVER_PORT 14445
-
-inline QUrl TEST_FILE(const QString &filename)
-{
- return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename);
-}
-
-#define TRY_WAIT(expr) \
- do { \
- for (int ii = 0; ii < 6; ++ii) { \
- if ((expr)) break; \
- QTest::qWait(50); \
- } \
- QVERIFY((expr)); \
- } while (false)
-
-class tst_QmlGraphicsLoader : public QObject
-
-{
- Q_OBJECT
-public:
- tst_QmlGraphicsLoader();
-
-private slots:
- void url();
- void invalidUrl();
- void component();
- void clear();
- void urlToComponent();
- void componentToUrl();
- void sizeLoaderToItem();
- void sizeItemToLoader();
- void noResize();
- void sizeLoaderToGraphicsWidget();
- void sizeGraphicsWidgetToLoader();
- void noResizeGraphicsWidget();
- void networkRequestUrl();
- void failNetworkRequest();
-// void networkComponent();
-
-private:
- QmlEngine engine;
-};
-
-
-tst_QmlGraphicsLoader::tst_QmlGraphicsLoader()
-{
-}
-
-void tst_QmlGraphicsLoader::url()
-{
- QmlComponent component(&engine);
- component.setData(QByteArray("import Qt 4.6\nLoader { source: \"Rect120x60.qml\" }"), TEST_FILE(""));
- QmlGraphicsLoader *loader = qobject_cast<QmlGraphicsLoader*>(component.create());
- QVERIFY(loader != 0);
- QVERIFY(loader->item());
- QVERIFY(loader->source() == QUrl::fromLocalFile(SRCDIR "/data/Rect120x60.qml"));
- QCOMPARE(loader->progress(), 1.0);
- QCOMPARE(loader->status(), QmlGraphicsLoader::Ready);
- QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 1);
-
- delete loader;
-}
-
-void tst_QmlGraphicsLoader::component()
-{
- QmlComponent component(&engine, TEST_FILE("/SetSourceComponent.qml"));
- QmlGraphicsItem *item = qobject_cast<QmlGraphicsItem*>(component.create());
- QVERIFY(item);
-
- QmlGraphicsLoader *loader = qobject_cast<QmlGraphicsLoader*>(item->QGraphicsObject::children().at(1));
- QVERIFY(loader);
- QVERIFY(loader->item());
- QCOMPARE(loader->progress(), 1.0);
- QCOMPARE(loader->status(), QmlGraphicsLoader::Ready);
- QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 1);
-
- delete loader;
-}
-
-void tst_QmlGraphicsLoader::invalidUrl()
-{
- QTest::ignoreMessage(QtWarningMsg, QString("(:-1: File error for URL " + QUrl::fromLocalFile(SRCDIR "/data/IDontExist.qml").toString() + ") ").toUtf8().constData());
-
- QmlComponent component(&engine);
- component.setData(QByteArray("import Qt 4.6\nLoader { source: \"IDontExist.qml\" }"), TEST_FILE(""));
- QmlGraphicsLoader *loader = qobject_cast<QmlGraphicsLoader*>(component.create());
- QVERIFY(loader != 0);
- QVERIFY(loader->item() == 0);
- QCOMPARE(loader->progress(), 1.0);
- QCOMPARE(loader->status(), QmlGraphicsLoader::Error);
- QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 0);
-
- delete loader;
-}
-
-void tst_QmlGraphicsLoader::clear()
-{
- {
- QmlComponent component(&engine);
- component.setData(QByteArray(
- "import Qt 4.6\n"
- " Loader { id: loader\n"
- " source: 'Rect120x60.qml'\n"
- " Timer { interval: 200; running: true; onTriggered: loader.source = '' }\n"
- " }")
- , TEST_FILE(""));
- QmlGraphicsLoader *loader = qobject_cast<QmlGraphicsLoader*>(component.create());
- QVERIFY(loader != 0);
- QVERIFY(loader->item());
- QCOMPARE(loader->progress(), 1.0);
- QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 1);
-
- QTest::qWait(500);
-
- QVERIFY(loader->item() == 0);
- QCOMPARE(loader->progress(), 0.0);
- QCOMPARE(loader->status(), QmlGraphicsLoader::Null);
- QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 0);
-
- delete loader;
- }
- {
- QmlComponent component(&engine, TEST_FILE("/SetSourceComponent.qml"));
- QmlGraphicsItem *item = qobject_cast<QmlGraphicsItem*>(component.create());
- QVERIFY(item);
-
- QmlGraphicsLoader *loader = qobject_cast<QmlGraphicsLoader*>(item->QGraphicsObject::children().at(1));
- QVERIFY(loader);
- QVERIFY(loader->item());
- QCOMPARE(loader->progress(), 1.0);
- QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 1);
-
- loader->setSourceComponent(0);
-
- QVERIFY(loader->item() == 0);
- QCOMPARE(loader->progress(), 0.0);
- QCOMPARE(loader->status(), QmlGraphicsLoader::Null);
- QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 0);
-
- delete loader;
- }
-}
-
-void tst_QmlGraphicsLoader::urlToComponent()
-{
- QmlComponent component(&engine);
- component.setData(QByteArray("import Qt 4.6\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"
- "}" )
- , TEST_FILE(""));
- QmlGraphicsLoader *loader = qobject_cast<QmlGraphicsLoader*>(component.create());
- QTest::qWait(500);
- QVERIFY(loader != 0);
- QVERIFY(loader->item());
- QCOMPARE(loader->progress(), 1.0);
- QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 1);
- QCOMPARE(loader->width(), 10.0);
- QCOMPARE(loader->height(), 10.0);
-
- delete loader;
-}
-
-void tst_QmlGraphicsLoader::componentToUrl()
-{
- QmlComponent component(&engine, TEST_FILE("/SetSourceComponent.qml"));
- QmlGraphicsItem *item = qobject_cast<QmlGraphicsItem*>(component.create());
- QVERIFY(item);
-
- QmlGraphicsLoader *loader = qobject_cast<QmlGraphicsLoader*>(item->QGraphicsObject::children().at(1));
- QVERIFY(loader);
- QVERIFY(loader->item());
- QCOMPARE(loader->progress(), 1.0);
- QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 1);
-
- loader->setSource(TEST_FILE("/Rect120x60.qml"));
- QVERIFY(loader->item());
- QCOMPARE(loader->progress(), 1.0);
- QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 1);
- QCOMPARE(loader->width(), 120.0);
- QCOMPARE(loader->height(), 60.0);
-
- delete loader;
-}
-
-void tst_QmlGraphicsLoader::sizeLoaderToItem()
-{
- QmlComponent component(&engine, TEST_FILE("/SizeToItem.qml"));
- QmlGraphicsLoader *loader = qobject_cast<QmlGraphicsLoader*>(component.create());
- QVERIFY(loader != 0);
- QVERIFY(loader->resizeMode() == QmlGraphicsLoader::SizeLoaderToItem);
- QCOMPARE(loader->width(), 120.0);
- QCOMPARE(loader->height(), 60.0);
-
- // Check resize
- QmlGraphicsItem *rect = qobject_cast<QmlGraphicsItem*>(loader->item());
- QVERIFY(rect);
- rect->setWidth(150);
- rect->setHeight(45);
- QCOMPARE(loader->width(), 150.0);
- QCOMPARE(loader->height(), 45.0);
-
- // Switch mode
- loader->setResizeMode(QmlGraphicsLoader::SizeItemToLoader);
- loader->setWidth(180);
- loader->setHeight(30);
- QCOMPARE(rect->width(), 180.0);
- QCOMPARE(rect->height(), 30.0);
-
- // notify
- QSignalSpy spy(loader, SIGNAL(resizeModeChanged()));
- loader->setResizeMode(QmlGraphicsLoader::NoResize);
- QCOMPARE(spy.count(),1);
- loader->setResizeMode(QmlGraphicsLoader::NoResize);
- QCOMPARE(spy.count(),1);
-}
-
-void tst_QmlGraphicsLoader::sizeItemToLoader()
-{
- QmlComponent component(&engine, TEST_FILE("/SizeToLoader.qml"));
- QmlGraphicsLoader *loader = qobject_cast<QmlGraphicsLoader*>(component.create());
- QVERIFY(loader != 0);
- QVERIFY(loader->resizeMode() == QmlGraphicsLoader::SizeItemToLoader);
- QCOMPARE(loader->width(), 200.0);
- QCOMPARE(loader->height(), 80.0);
-
- QmlGraphicsItem *rect = qobject_cast<QmlGraphicsItem*>(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->setResizeMode(QmlGraphicsLoader::SizeLoaderToItem);
- rect->setWidth(160);
- rect->setHeight(45);
- QCOMPARE(loader->width(), 160.0);
- QCOMPARE(loader->height(), 45.0);
-}
-
-void tst_QmlGraphicsLoader::noResize()
-{
- QmlComponent component(&engine, TEST_FILE("/NoResize.qml"));
- QmlGraphicsLoader *loader = qobject_cast<QmlGraphicsLoader*>(component.create());
- QVERIFY(loader != 0);
- QCOMPARE(loader->width(), 200.0);
- QCOMPARE(loader->height(), 80.0);
-
- QmlGraphicsItem *rect = qobject_cast<QmlGraphicsItem*>(loader->item());
- QVERIFY(rect);
- QCOMPARE(rect->width(), 120.0);
- QCOMPARE(rect->height(), 60.0);
-}
-
-void tst_QmlGraphicsLoader::sizeLoaderToGraphicsWidget()
-{
- QmlComponent component(&engine, TEST_FILE("/SizeLoaderToGraphicsWidget.qml"));
- QmlGraphicsLoader *loader = qobject_cast<QmlGraphicsLoader*>(component.create());
- QGraphicsScene scene;
- scene.addItem(loader);
-
- QVERIFY(loader != 0);
- QVERIFY(loader->resizeMode() == QmlGraphicsLoader::SizeLoaderToItem);
- QCOMPARE(loader->width(), 250.0);
- QCOMPARE(loader->height(), 250.0);
-
- // Check resize
- QGraphicsWidget *widget = qobject_cast<QGraphicsWidget*>(loader->item());
- QVERIFY(widget);
- widget->resize(QSizeF(150,45));
- QCOMPARE(loader->width(), 150.0);
- QCOMPARE(loader->height(), 45.0);
-
- // Switch mode
- loader->setResizeMode(QmlGraphicsLoader::SizeItemToLoader);
- loader->setWidth(180);
- loader->setHeight(30);
- QCOMPARE(widget->size().width(), 180.0);
- QCOMPARE(widget->size().height(), 30.0);
-}
-
-void tst_QmlGraphicsLoader::sizeGraphicsWidgetToLoader()
-{
- QmlComponent component(&engine, TEST_FILE("/SizeGraphicsWidgetToLoader.qml"));
- QmlGraphicsLoader *loader = qobject_cast<QmlGraphicsLoader*>(component.create());
- QGraphicsScene scene;
- scene.addItem(loader);
-
- QVERIFY(loader != 0);
- QVERIFY(loader->resizeMode() == QmlGraphicsLoader::SizeItemToLoader);
- QCOMPARE(loader->width(), 200.0);
- QCOMPARE(loader->height(), 80.0);
-
- QGraphicsWidget *widget = qobject_cast<QGraphicsWidget*>(loader->item());
- QVERIFY(widget);
- QCOMPARE(widget->size().width(), 200.0);
- QCOMPARE(widget->size().height(), 80.0);
-
- // Check resize
- loader->setWidth(180);
- loader->setHeight(30);
- QCOMPARE(widget->size().width(), 180.0);
- QCOMPARE(widget->size().height(), 30.0);
-
- // Switch mode
- loader->setResizeMode(QmlGraphicsLoader::SizeLoaderToItem);
- widget->resize(QSizeF(160,45));
- QCOMPARE(loader->width(), 160.0);
- QCOMPARE(loader->height(), 45.0);
-}
-
-void tst_QmlGraphicsLoader::noResizeGraphicsWidget()
-{
- QmlComponent component(&engine, TEST_FILE("/NoResizeGraphicsWidget.qml"));
- QmlGraphicsLoader *loader = qobject_cast<QmlGraphicsLoader*>(component.create());
- QGraphicsScene scene;
- scene.addItem(loader);
-
- QVERIFY(loader != 0);
- QCOMPARE(loader->width(), 200.0);
- QCOMPARE(loader->height(), 80.0);
-
- QGraphicsWidget *widget = qobject_cast<QGraphicsWidget*>(loader->item());
- QVERIFY(widget);
- QCOMPARE(widget->size().width(), 250.0);
- QCOMPARE(widget->size().height(), 250.0);
-}
-
-void tst_QmlGraphicsLoader::networkRequestUrl()
-{
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- server.serveDirectory(SRCDIR "/data");
-
- QmlComponent component(&engine);
- component.setData(QByteArray("import Qt 4.6\nLoader { source: \"http://127.0.0.1:14445/Rect120x60.qml\" }"), TEST_FILE(""));
- QmlGraphicsLoader *loader = qobject_cast<QmlGraphicsLoader*>(component.create());
- QVERIFY(loader != 0);
-
- TRY_WAIT(loader->status() == QmlGraphicsLoader::Ready);
-
- QVERIFY(loader->item());
- QCOMPARE(loader->progress(), 1.0);
- QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 1);
-
- delete loader;
-}
-
-/* XXX Component waits until all dependencies are loaded. Is this actually possible?
-void tst_QmlGraphicsLoader::networkComponent()
-{
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- server.serveDirectory("slowdata", TestHTTPServer::Delay);
-
- QmlComponent component(&engine);
- component.setData(QByteArray(
- "import Qt 4.6\n"
- "import \"http://127.0.0.1:14445/\" as NW\n"
- "Item {\n"
- " Component { id: comp; NW.SlowRect {} }\n"
- " Loader { sourceComponent: comp } }")
- , TEST_FILE(""));
-
- QmlGraphicsItem *item = qobject_cast<QmlGraphicsItem*>(component.create());
- QVERIFY(item);
-
- QmlGraphicsLoader *loader = qobject_cast<QmlGraphicsLoader*>(item->QGraphicsObject::children().at(1));
- QVERIFY(loader);
- TRY_WAIT(loader->status() == QmlGraphicsLoader::Ready);
-
- QVERIFY(loader->item());
- QCOMPARE(loader->progress(), 1.0);
- QCOMPARE(loader->status(), QmlGraphicsLoader::Ready);
- QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 1);
-
- delete loader;
-}
-*/
-
-void tst_QmlGraphicsLoader::failNetworkRequest()
-{
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- server.serveDirectory(SRCDIR "/data");
-
- QTest::ignoreMessage(QtWarningMsg, "(:-1: Network error for URL http://127.0.0.1:14445/IDontExist.qml) ");
-
- QmlComponent component(&engine);
- component.setData(QByteArray("import Qt 4.6\nLoader { source: \"http://127.0.0.1:14445/IDontExist.qml\" }"), TEST_FILE(""));
- QmlGraphicsLoader *loader = qobject_cast<QmlGraphicsLoader*>(component.create());
- QVERIFY(loader != 0);
-
- TRY_WAIT(loader->status() == QmlGraphicsLoader::Error);
-
- QVERIFY(loader->item() == 0);
- QCOMPARE(loader->progress(), 0.0);
- QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 0);
-
- delete loader;
-}
-
-QTEST_MAIN(tst_QmlGraphicsLoader)
-
-#include "tst_qmlgraphicsloader.moc"
diff --git a/tests/auto/declarative/qmlgraphicsmousearea/qmlgraphicsmousearea.pro b/tests/auto/declarative/qmlgraphicsmousearea/qmlgraphicsmousearea.pro
deleted file mode 100644
index f85bf0f..0000000
--- a/tests/auto/declarative/qmlgraphicsmousearea/qmlgraphicsmousearea.pro
+++ /dev/null
@@ -1,9 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative gui network
-macx:CONFIG -= app_bundle
-
-HEADERS += ../shared/testhttpserver.h
-SOURCES += tst_qmlgraphicsmousearea.cpp ../shared/testhttpserver.cpp
-
-# Define SRCDIR equal to test's source directory
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmlgraphicsmousearea/tst_qmlgraphicsmousearea.cpp b/tests/auto/declarative/qmlgraphicsmousearea/tst_qmlgraphicsmousearea.cpp
deleted file mode 100644
index 869a7bd..0000000
--- a/tests/auto/declarative/qmlgraphicsmousearea/tst_qmlgraphicsmousearea.cpp
+++ /dev/null
@@ -1,139 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtTest/QtTest>
-#include <QtTest/QSignalSpy>
-#include <private/qmlgraphicsmousearea_p.h>
-#include <QtDeclarative/qmlview.h>
-
-class tst_QmlGraphicsMouseArea: public QObject
-{
- Q_OBJECT
-private slots:
- void dragProperties();
-private:
- QmlView *createView(const QString &filename);
-};
-
-void tst_QmlGraphicsMouseArea::dragProperties()
-{
- QmlView *canvas = createView(SRCDIR "/data/dragproperties.qml");
- canvas->execute();
- canvas->show();
- canvas->setFocus();
- QVERIFY(canvas->rootObject() != 0);
-
- QmlGraphicsMouseArea *mouseRegion = canvas->rootObject()->findChild<QmlGraphicsMouseArea*>("mouseregion");
- QmlGraphicsDrag *drag = mouseRegion->drag();
- QVERIFY(mouseRegion != 0);
- QVERIFY(drag != 0);
-
- // target
- QmlGraphicsItem *blackRect = canvas->rootObject()->findChild<QmlGraphicsItem*>("blackrect");
- QVERIFY(blackRect != 0);
- QVERIFY(blackRect == drag->target());
- QmlGraphicsItem *rootItem = qobject_cast<QmlGraphicsItem*>(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(), QmlGraphicsDrag::XandYAxis);
- QSignalSpy axisSpy(drag, SIGNAL(axisChanged()));
- drag->setAxis(QmlGraphicsDrag::XAxis);
- QCOMPARE(drag->axis(), QmlGraphicsDrag::XAxis);
- QCOMPARE(axisSpy.count(),1);
- drag->setAxis(QmlGraphicsDrag::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);
-}
-
-QmlView *tst_QmlGraphicsMouseArea::createView(const QString &filename)
-{
- QmlView *canvas = new QmlView(0);
- canvas->setFixedSize(240,320);
-
- canvas->setSource(QUrl::fromLocalFile(filename));
-
- return canvas;
-}
-
-QTEST_MAIN(tst_QmlGraphicsMouseArea)
-
-#include "tst_qmlgraphicsmousearea.moc"
diff --git a/tests/auto/declarative/qmlgraphicsparticles/qmlgraphicsparticles.pro b/tests/auto/declarative/qmlgraphicsparticles/qmlgraphicsparticles.pro
deleted file mode 100644
index 94eeb4e..0000000
--- a/tests/auto/declarative/qmlgraphicsparticles/qmlgraphicsparticles.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative gui
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qmlgraphicsparticles.cpp
-
-# Define SRCDIR equal to test's source directory
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmlgraphicsparticles/tst_qmlgraphicsparticles.cpp b/tests/auto/declarative/qmlgraphicsparticles/tst_qmlgraphicsparticles.cpp
deleted file mode 100644
index a5c0b78..0000000
--- a/tests/auto/declarative/qmlgraphicsparticles/tst_qmlgraphicsparticles.cpp
+++ /dev/null
@@ -1,122 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <QtTest/QtTest>
-#include <qmlview.h>
-#include <private/qmlgraphicsparticles_p.h>
-
-class tst_QmlGraphicsParticles : public QObject
-{
- Q_OBJECT
-public:
- tst_QmlGraphicsParticles();
-
-private slots:
- void properties();
- void runs();
-private:
- QmlView *createView(const QString &filename);
-
-};
-
-tst_QmlGraphicsParticles::tst_QmlGraphicsParticles()
-{
-}
-
-void tst_QmlGraphicsParticles::properties()
-{
- QmlView *canvas = createView(SRCDIR "/data/particles.qml");
- QVERIFY(canvas->rootObject());
- QmlGraphicsParticles* particles = canvas->rootObject()->findChild<QmlGraphicsParticles*>("particles");
- QVERIFY(particles);
-
- particles->setSource(QUrl::fromLocalFile(SRCDIR "/data/particle.png"));
- QCOMPARE(particles->source(), QUrl::fromLocalFile(SRCDIR "/data/particle.png"));
-
- particles->setLifeSpanDeviation(1000);
- QCOMPARE(particles->lifeSpanDeviation(), 1000);
-
- particles->setFadeInDuration(1000);
- QCOMPARE(particles->fadeInDuration(), 1000);
-
- particles->setFadeOutDuration(1000);
- QCOMPARE(particles->fadeOutDuration(), 1000);
-
- particles->setAngle(100.0);
- QCOMPARE(particles->angle(), 100.0);
-
- particles->setAngleDeviation(100.0);
- QCOMPARE(particles->angleDeviation(), 100.0);
-
- particles->setVelocity(100.0);
- QCOMPARE(particles->velocity(), 100.0);
-
- particles->setVelocityDeviation(100.0);
- QCOMPARE(particles->velocityDeviation(), 100.0);
-
- particles->setEmissionVariance(0.5);
- QCOMPARE(particles->emissionVariance(),0.5);
-
- particles->setEmissionRate(12);
- QCOMPARE(particles->emissionRate(), 12);
-}
-
-void tst_QmlGraphicsParticles::runs()
-{
- QmlView *canvas = createView(SRCDIR "/data/particles.qml");
- QVERIFY(canvas->rootObject());
- QmlGraphicsParticles* particles = canvas->rootObject()->findChild<QmlGraphicsParticles*>("particles");
- QVERIFY(particles);
- QTest::qWait(1000);//Run for one second. Test passes if it doesn't crash.
-}
-
-QmlView *tst_QmlGraphicsParticles::createView(const QString &filename)
-{
- QmlView *canvas = new QmlView(0);
- canvas->setFixedSize(240,320);
-
- canvas->setSource(QUrl::fromLocalFile(filename));
- canvas->execute();
-
- return canvas;
-}
-QTEST_MAIN(tst_QmlGraphicsParticles)
-
-#include "tst_qmlgraphicsparticles.moc"
diff --git a/tests/auto/declarative/qmlgraphicspathview/qmlgraphicspathview.pro b/tests/auto/declarative/qmlgraphicspathview/qmlgraphicspathview.pro
deleted file mode 100644
index 142a256..0000000
--- a/tests/auto/declarative/qmlgraphicspathview/qmlgraphicspathview.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qmlgraphicspathview.cpp
-
-# Define SRCDIR equal to test's source directory
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmlgraphicspathview/tst_qmlgraphicspathview.cpp b/tests/auto/declarative/qmlgraphicspathview/tst_qmlgraphicspathview.cpp
deleted file mode 100644
index b986a64..0000000
--- a/tests/auto/declarative/qmlgraphicspathview/tst_qmlgraphicspathview.cpp
+++ /dev/null
@@ -1,491 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <private/qmlgraphicspathview_p.h>
-#include <private/qmlgraphicspath_p.h>
-#include <qmlcontext.h>
-#include <qmlexpression.h>
-#include <qtest.h>
-#include <QtDeclarative/qmlengine.h>
-#include <QtDeclarative/qmlcomponent.h>
-#include <QtDeclarative/qmlview.h>
-#include <QtDeclarative/private/qmlgraphicstext_p.h>
-#include <QtDeclarative/private/qmlgraphicsrectangle_p.h>
-#include <QAbstractListModel>
-#include <QFile>
-#include <private/qmlvaluetype_p.h>
-#include "../../../shared/util.h"
-
-class tst_QmlGraphicsPathView : public QObject
-{
- Q_OBJECT
-public:
- tst_QmlGraphicsPathView();
-
-private slots:
- void initValues();
- void items();
- void dataModel();
- void pathview2();
- void pathview3();
- void path();
- void pathMoved();
-
-private:
- QmlView *createView(const QString &filename);
- template<typename T>
- T *findItem(QGraphicsObject *parent, const QString &objectName, int index=-1);
- template<typename T>
- QList<T*> findItems(QGraphicsObject *parent, const QString &objectName);
-};
-
-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;
-};
-
-class TestModel : public QAbstractListModel
-{
-public:
- enum Roles { Name = Qt::UserRole+1, Number = Qt::UserRole+2 };
-
- TestModel(QObject *parent=0) : QAbstractListModel(parent) {
- QHash<int, QByteArray> roles;
- roles[Name] = "name";
- roles[Number] = "number";
- setRoleNames(roles);
- }
-
- int rowCount(const QModelIndex &parent=QModelIndex()) const { return list.count(); }
- QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) 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 count() const { return rowCount(); }
- QString name(int index) const { return list.at(index).first; }
- QString number(int index) const { return list.at(index).second; }
-
- void addItem(const QString &name, const QString &number) {
- emit beginInsertRows(QModelIndex(), list.count(), list.count());
- list.append(QPair<QString,QString>(name, number));
- emit endInsertRows();
- }
-
- void 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 removeItem(int index) {
- emit beginRemoveRows(QModelIndex(), index, index);
- list.removeAt(index);
- emit endRemoveRows();
- }
-
- void moveItem(int from, int to) {
- emit beginMoveRows(QModelIndex(), from, from, QModelIndex(), to);
- list.move(from, to);
- emit endMoveRows();
- }
-
- void modifyItem(int idx, const QString &name, const QString &number) {
- list[idx] = QPair<QString,QString>(name, number);
- emit dataChanged(index(idx,0), index(idx,0));
- }
-
-private:
- QList<QPair<QString,QString> > list;
-};
-
-
-tst_QmlGraphicsPathView::tst_QmlGraphicsPathView()
-{
-}
-
-void tst_QmlGraphicsPathView::initValues()
-{
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/pathview1.qml"));
- QmlGraphicsPathView *obj = qobject_cast<QmlGraphicsPathView*>(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->snapPosition(), 0.);
- QCOMPARE(obj->dragMargin(), 0.);
- QCOMPARE(obj->count(), 0);
- QCOMPARE(obj->pathItemCount(), -1);
-}
-
-void tst_QmlGraphicsPathView::items()
-{
- QmlView *canvas = createView(SRCDIR "/data/pathview.qml");
-
- TestModel model;
- model.addItem("Fred", "12345");
- model.addItem("John", "2345");
- model.addItem("Bob", "54321");
-
- QmlContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- canvas->execute();
- qApp->processEvents();
-
- QmlGraphicsPathView *pathview = findItem<QmlGraphicsPathView>(canvas->rootObject(), "view");
- QVERIFY(pathview != 0);
-
- QCOMPARE(pathview->childItems().count(), model.count()); // assumes all are visible
-
- for (int i = 0; i < model.count(); ++i) {
- QmlGraphicsText *name = findItem<QmlGraphicsText>(pathview, "textName", i);
- QVERIFY(name != 0);
- QCOMPARE(name->text(), model.name(i));
- QmlGraphicsText *number = findItem<QmlGraphicsText>(pathview, "textNumber", i);
- QVERIFY(number != 0);
- QCOMPARE(number->text(), model.number(i));
- }
-
- delete canvas;
-}
-
-void tst_QmlGraphicsPathView::pathview2()
-{
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/pathview2.qml"));
- QmlGraphicsPathView *obj = qobject_cast<QmlGraphicsPathView*>(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->snapPosition(), 0.);
- QCOMPARE(obj->dragMargin(), 0.);
- QCOMPARE(obj->count(), 8);
- QCOMPARE(obj->pathItemCount(), 10);
-}
-
-void tst_QmlGraphicsPathView::pathview3()
-{
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/pathview3.qml"));
- QmlGraphicsPathView *obj = qobject_cast<QmlGraphicsPathView*>(c.create());
-
- QVERIFY(obj != 0);
- QVERIFY(obj->path() != 0);
- QVERIFY(obj->delegate() != 0);
- QVERIFY(obj->model() != QVariant());
- QCOMPARE(obj->currentIndex(), 0);
- QCOMPARE(obj->offset(), 50.); // ???
- QCOMPARE(obj->snapPosition(), 0.5); // ???
- QCOMPARE(obj->dragMargin(), 24.);
- QCOMPARE(obj->count(), 8);
- QCOMPARE(obj->pathItemCount(), 4);
-}
-
-void tst_QmlGraphicsPathView::path()
-{
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/path.qml"));
- QmlGraphicsPath *obj = qobject_cast<QmlGraphicsPath*>(c.create());
-
- QVERIFY(obj != 0);
- QCOMPARE(obj->startX(), 120.);
- QCOMPARE(obj->startY(), 100.);
- QVERIFY(obj->path() != QPainterPath());
-
- QmlListReference list(obj, "pathElements");
- QCOMPARE(list.count(), 5);
-
- QmlGraphicsPathAttribute* attr = qobject_cast<QmlGraphicsPathAttribute*>(list.at(0));
- QVERIFY(attr != 0);
- QCOMPARE(attr->name(), QString("scale"));
- QCOMPARE(attr->value(), 1.0);
-
- QmlGraphicsPathQuad* quad = qobject_cast<QmlGraphicsPathQuad*>(list.at(1));
- QVERIFY(quad != 0);
- QCOMPARE(quad->x(), 120.);
- QCOMPARE(quad->y(), 25.);
- QCOMPARE(quad->controlX(), 260.);
- QCOMPARE(quad->controlY(), 75.);
-
- QmlGraphicsPathPercent* perc = qobject_cast<QmlGraphicsPathPercent*>(list.at(2));
- QVERIFY(perc != 0);
- QCOMPARE(perc->value(), 0.3);
-
- QmlGraphicsPathLine* line = qobject_cast<QmlGraphicsPathLine*>(list.at(3));
- QVERIFY(line != 0);
- QCOMPARE(line->x(), 120.);
- QCOMPARE(line->y(), 100.);
-
- QmlGraphicsPathCubic* cubic = qobject_cast<QmlGraphicsPathCubic*>(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.);
-}
-
-void tst_QmlGraphicsPathView::dataModel()
-{
- QmlView *canvas = createView(SRCDIR "/data/datamodel.qml");
-
- QmlContext *ctxt = canvas->rootContext();
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
-
- TestModel 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");
-
- ctxt->setContextProperty("testData", &model);
-
- canvas->execute();
- qApp->processEvents();
-
- QmlGraphicsPathView *pathview = qobject_cast<QmlGraphicsPathView*>(canvas->rootObject());
- QVERIFY(pathview != 0);
-
- QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
- QVERIFY(testObject->error() == false);
-
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(pathview, "wrapper", 0);
- QVERIFY(item);
- QCOMPARE(item->x(), 110.0);
- QCOMPARE(item->y(), 10.0);
-
- model.insertItem(4, "orange", "10");
-
- int itemCount = findItems<QmlGraphicsItem>(pathview, "wrapper").count();
- QCOMPARE(itemCount, 10);
-
- QmlGraphicsText *text = findItem<QmlGraphicsText>(pathview, "myText", 4);
- QVERIFY(text);
- QCOMPARE(text->text(), model.name(4));
-
- model.removeItem(2);
- text = findItem<QmlGraphicsText>(pathview, "myText", 2);
- QVERIFY(text);
- QCOMPARE(text->text(), model.name(2));
-
- testObject->setPathItemCount(5);
- QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
- QVERIFY(testObject->error() == false);
-
- itemCount = findItems<QmlGraphicsItem>(pathview, "wrapper").count();
- QCOMPARE(itemCount, 5);
-
- QmlGraphicsRectangle *testItem = findItem<QmlGraphicsRectangle>(pathview, "wrapper", 4);
- QVERIFY(testItem != 0);
- testItem = findItem<QmlGraphicsRectangle>(pathview, "wrapper", 5);
- QVERIFY(testItem == 0);
-
- model.insertItem(2, "pink", "2");
-
- itemCount = findItems<QmlGraphicsItem>(pathview, "wrapper").count();
- QCOMPARE(itemCount, 5);
-
- text = findItem<QmlGraphicsText>(pathview, "myText", 2);
- QVERIFY(text);
- QCOMPARE(text->text(), model.name(2));
-
- model.removeItem(3);
- itemCount = findItems<QmlGraphicsItem>(pathview, "wrapper").count();
- QCOMPARE(itemCount, 5);
- text = findItem<QmlGraphicsText>(pathview, "myText", 3);
- QVERIFY(text);
- QCOMPARE(text->text(), model.name(3));
-
- delete canvas;
-}
-
-void tst_QmlGraphicsPathView::pathMoved()
-{
- QmlView *canvas = createView(SRCDIR "/data/pathview.qml");
-
- TestModel model;
- model.addItem("Ben", "12345");
- model.addItem("Bohn", "2345");
- model.addItem("Bob", "54321");
- model.addItem("Bill", "4321");
-
- QmlContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- canvas->execute();
- qApp->processEvents();
-
- QmlGraphicsPathView *pathview = findItem<QmlGraphicsPathView>(canvas->rootObject(), "view");
- QVERIFY(pathview != 0);
-
- QmlGraphicsRectangle *firstItem = findItem<QmlGraphicsRectangle>(pathview, "wrapper", 0);
- QVERIFY(firstItem);
- QmlGraphicsPath *path = qobject_cast<QmlGraphicsPath*>(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);
- pathview->setOffset(10);
- QTest::qWait(1000);//Moving is animated?
-
- for(int i=0; i<model.count(); i++){
- QmlGraphicsRectangle *curItem = findItem<QmlGraphicsRectangle>(pathview, "wrapper", i);
- QCOMPARE(curItem->pos() + offset, path->pointAt(0.1 + i*0.25));
- }
-
- pathview->setOffset(100);
- QTest::qWait(1000);//Moving is animated?
- QCOMPARE(firstItem->pos() + offset, start);
-
- delete canvas;
-}
-
-QmlView *tst_QmlGraphicsPathView::createView(const QString &filename)
-{
- QmlView *canvas = new QmlView(0);
- canvas->setFixedSize(240,320);
-
- canvas->setSource(QUrl::fromLocalFile(filename));
-
- return canvas;
-}
-
-/*
- 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 *tst_QmlGraphicsPathView::findItem(QGraphicsObject *parent, const QString &objectName, int index)
-{
- const QMetaObject &mo = T::staticMetaObject;
- //qDebug() << parent->childItems().count() << "children";
- for (int i = 0; i < parent->childItems().count(); ++i) {
- QmlGraphicsItem *item = qobject_cast<QmlGraphicsItem*>(parent->childItems().at(i));
- if(!item)
- continue;
- //qDebug() << "try" << item;
- if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) {
- if (index != -1) {
- QmlExpression e(qmlContext(item), "index", item);
- e.setTrackChange(false);
- if (e.value().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*> tst_QmlGraphicsPathView::findItems(QGraphicsObject *parent, const QString &objectName)
-{
- QList<T*> items;
- const QMetaObject &mo = T::staticMetaObject;
- //qDebug() << parent->QGraphicsObject::children().count() << "children";
- for (int i = 0; i < parent->childItems().count(); ++i) {
- QmlGraphicsItem *item = qobject_cast<QmlGraphicsItem*>(parent->childItems().at(i));
- if(!item)
- continue;
- //qDebug() << "try" << item;
- if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName))
- items.append(static_cast<T*>(item));
- items += findItems<T>(item, objectName);
- }
-
- return items;
-}
-
-QTEST_MAIN(tst_QmlGraphicsPathView)
-
-#include "tst_qmlgraphicspathview.moc"
diff --git a/tests/auto/declarative/qmlgraphicspositioners/qmlgraphicspositioners.pro b/tests/auto/declarative/qmlgraphicspositioners/qmlgraphicspositioners.pro
deleted file mode 100644
index d151026..0000000
--- a/tests/auto/declarative/qmlgraphicspositioners/qmlgraphicspositioners.pro
+++ /dev/null
@@ -1,7 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative
-SOURCES += tst_qmlgraphicspositioners.cpp
-macx:CONFIG -= app_bundle
-
-# Define SRCDIR equal to test's source directory
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmlgraphicspositioners/tst_qmlgraphicspositioners.cpp b/tests/auto/declarative/qmlgraphicspositioners/tst_qmlgraphicspositioners.cpp
deleted file mode 100644
index b51266a..0000000
--- a/tests/auto/declarative/qmlgraphicspositioners/tst_qmlgraphicspositioners.cpp
+++ /dev/null
@@ -1,417 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <QtTest/QtTest>
-#include <private/qlistmodelinterface_p.h>
-#include <qmlview.h>
-#include <private/qmlgraphicsrectangle_p.h>
-#include <qmlexpression.h>
-#include "../../../shared/util.h"
-
-class tst_QmlGraphicsPositioners : public QObject
-{
- Q_OBJECT
-public:
- tst_QmlGraphicsPositioners();
-
-private slots:
- void test_horizontal();
- void test_horizontal_spacing();
- void test_horizontal_animated();
- void test_vertical();
- void test_vertical_spacing();
- void test_vertical_animated();
- void test_grid();
- void test_grid_spacing();
- void test_grid_animated();
-
- void test_repeater();
-private:
- QmlView *createView(const QString &filename);
-};
-
-tst_QmlGraphicsPositioners::tst_QmlGraphicsPositioners()
-{
-}
-
-void tst_QmlGraphicsPositioners::test_horizontal()
-{
- QmlView *canvas = createView(SRCDIR "/data/horizontal.qml");
-
- canvas->execute();
-
- QmlGraphicsRectangle *one = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("one");
- QVERIFY(one != 0);
-
- QmlGraphicsRectangle *two = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("two");
- QVERIFY(two != 0);
-
- QmlGraphicsRectangle *three = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("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);
-}
-
-void tst_QmlGraphicsPositioners::test_horizontal_spacing()
-{
- QmlView *canvas = createView(SRCDIR "/data/horizontal-spacing.qml");
-
- canvas->execute();
-
- QmlGraphicsRectangle *one = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("one");
- QVERIFY(one != 0);
-
- QmlGraphicsRectangle *two = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("two");
- QVERIFY(two != 0);
-
- QmlGraphicsRectangle *three = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("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);
-}
-
-void tst_QmlGraphicsPositioners::test_horizontal_animated()
-{
- QmlView *canvas = createView(SRCDIR "/data/horizontal-animated.qml");
-
- canvas->execute();
-
- QmlGraphicsRectangle *one = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("one");
- QVERIFY(one != 0);
-
- QmlGraphicsRectangle *two = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("two");
- QVERIFY(two != 0);
-
- QmlGraphicsRectangle *three = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("three");
- QVERIFY(three != 0);
-
- //Note that they animate in
- QCOMPARE(one->x(), -100.0);
- QCOMPARE(two->x(), -100.0);
- QCOMPARE(three->x(), -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->x(), 0.0);
- QTRY_COMPARE(one->y(), 0.0);
- QTRY_COMPARE(two->opacity(), 0.0);
- 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->setOpacity(1.0);
- QCOMPARE(two->opacity(), 1.0);
- QTest::qWait(0);//Let the animation start
- QCOMPARE(two->x(), -100.0);
- QCOMPARE(three->x(), 50.0);
-
- QTRY_COMPARE(two->x(), 50.0);
- QTRY_COMPARE(three->x(), 100.0);
-}
-
-void tst_QmlGraphicsPositioners::test_vertical()
-{
- QmlView *canvas = createView(SRCDIR "/data/vertical.qml");
-
- canvas->execute();
-
- QmlGraphicsRectangle *one = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("one");
- QVERIFY(one != 0);
-
- QmlGraphicsRectangle *two = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("two");
- QVERIFY(two != 0);
-
- QmlGraphicsRectangle *three = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("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);
-}
-
-void tst_QmlGraphicsPositioners::test_vertical_spacing()
-{
- QmlView *canvas = createView(SRCDIR "/data/vertical-spacing.qml");
-
- canvas->execute();
-
- QmlGraphicsRectangle *one = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("one");
- QVERIFY(one != 0);
-
- QmlGraphicsRectangle *two = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("two");
- QVERIFY(two != 0);
-
- QmlGraphicsRectangle *three = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("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);
-}
-
-void tst_QmlGraphicsPositioners::test_vertical_animated()
-{
- QmlView *canvas = createView(SRCDIR "/data/vertical-animated.qml");
-
- canvas->execute();
-
- //Note that they animate in
- QmlGraphicsRectangle *one = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("one");
- QVERIFY(one != 0);
- QCOMPARE(one->y(), -100.0);
-
- QmlGraphicsRectangle *two = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("two");
- QVERIFY(two != 0);
- QCOMPARE(two->y(), -100.0);
-
- QmlGraphicsRectangle *three = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("three");
- QVERIFY(three != 0);
- QCOMPARE(three->y(), -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->opacity(), 0.0);
- 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->setOpacity(1.0);
- QTRY_COMPARE(two->opacity(), 1.0);
- QTest::qWait(0);//Let the animation start
- QCOMPARE(two->y(), -100.0);
- QCOMPARE(three->y(), 50.0);
-
- QTRY_COMPARE(two->y(), 50.0);
- QTRY_COMPARE(three->y(), 100.0);
-
-}
-
-void tst_QmlGraphicsPositioners::test_grid()
-{
- QmlView *canvas = createView("data/grid.qml");
-
- canvas->execute();
-
- QmlGraphicsRectangle *one = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("one");
- QVERIFY(one != 0);
- QmlGraphicsRectangle *two = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("two");
- QVERIFY(two != 0);
- QmlGraphicsRectangle *three = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("three");
- QVERIFY(three != 0);
- QmlGraphicsRectangle *four = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("four");
- QVERIFY(four != 0);
- QmlGraphicsRectangle *five = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("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);
-}
-
-void tst_QmlGraphicsPositioners::test_grid_spacing()
-{
- QmlView *canvas = createView("data/grid-spacing.qml");
-
- canvas->execute();
-
- QmlGraphicsRectangle *one = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("one");
- QVERIFY(one != 0);
- QmlGraphicsRectangle *two = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("two");
- QVERIFY(two != 0);
- QmlGraphicsRectangle *three = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("three");
- QVERIFY(three != 0);
- QmlGraphicsRectangle *four = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("four");
- QVERIFY(four != 0);
- QmlGraphicsRectangle *five = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("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);
-}
-
-void tst_QmlGraphicsPositioners::test_grid_animated()
-{
- QmlView *canvas = createView(SRCDIR "/data/grid-animated.qml");
- canvas->execute();
-
- //Note that all animate in
- QmlGraphicsRectangle *one = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("one");
- QVERIFY(one != 0);
- QCOMPARE(one->x(), -100.0);
- QCOMPARE(one->y(), -100.0);
-
- QmlGraphicsRectangle *two = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("two");
- QVERIFY(two != 0);
- QCOMPARE(two->x(), -100.0);
- QCOMPARE(two->y(), -100.0);
-
- QmlGraphicsRectangle *three = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("three");
- QVERIFY(three != 0);
- QCOMPARE(three->x(), -100.0);
- QCOMPARE(three->y(), -100.0);
-
- QmlGraphicsRectangle *four = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("four");
- QVERIFY(four != 0);
- QCOMPARE(four->x(), -100.0);
- QCOMPARE(four->y(), -100.0);
-
- QmlGraphicsRectangle *five = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("five");
- QVERIFY(five != 0);
- QCOMPARE(five->x(), -100.0);
- QCOMPARE(five->y(), -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->opacity(), 0.0);
- 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->setOpacity(1.0);
- QCOMPARE(two->opacity(), 1.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);
-
-}
-
-void tst_QmlGraphicsPositioners::test_repeater()
-{
- QmlView *canvas = createView("data/repeater.qml");
-
- canvas->execute();
-
- QmlGraphicsRectangle *one = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("one");
- QVERIFY(one != 0);
-
- QmlGraphicsRectangle *two = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("two");
- QVERIFY(two != 0);
-
- QmlGraphicsRectangle *three = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("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);
-}
-
-QmlView *tst_QmlGraphicsPositioners::createView(const QString &filename)
-{
- QmlView *canvas = new QmlView(0);
-
- canvas->setSource(QUrl::fromLocalFile(filename));
-
- return canvas;
-}
-
-
-QTEST_MAIN(tst_QmlGraphicsPositioners)
-
-#include "tst_qmlgraphicspositioners.moc"
diff --git a/tests/auto/declarative/qmlgraphicsrepeater/qmlgraphicsrepeater.pro b/tests/auto/declarative/qmlgraphicsrepeater/qmlgraphicsrepeater.pro
deleted file mode 100644
index 0a10ec6..0000000
--- a/tests/auto/declarative/qmlgraphicsrepeater/qmlgraphicsrepeater.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qmlgraphicsrepeater.cpp
-
-# Define SRCDIR equal to test's source directory
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmlgraphicsrepeater/tst_qmlgraphicsrepeater.cpp b/tests/auto/declarative/qmlgraphicsrepeater/tst_qmlgraphicsrepeater.cpp
deleted file mode 100644
index c971840..0000000
--- a/tests/auto/declarative/qmlgraphicsrepeater/tst_qmlgraphicsrepeater.cpp
+++ /dev/null
@@ -1,387 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtTest/QtTest>
-#include <QtTest/QSignalSpy>
-#include <private/qlistmodelinterface_p.h>
-#include <QtDeclarative/qmlengine.h>
-#include <QtDeclarative/qmlview.h>
-#include <QtDeclarative/qmlcontext.h>
-#include <private/qmlgraphicsrepeater_p.h>
-#include <private/qmlgraphicstext_p.h>
-
-inline QUrl TEST_FILE(const QString &filename)
-{
- return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename);
-}
-
-class tst_QmlGraphicsRepeater : public QObject
-{
- Q_OBJECT
-public:
- tst_QmlGraphicsRepeater();
-
-private slots:
- void numberModel();
- void objectList();
- void stringList();
- void dataModel();
- void itemModel();
- void properties();
-
-private:
- QmlView *createView(const QString &filename);
- template<typename T>
- T *findItem(QGraphicsObject *parent, const QString &id);
-};
-
-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;
-};
-
-class TestModel : public QAbstractListModel
-{
-public:
- enum Roles { Name = Qt::UserRole+1, Number = Qt::UserRole+2 };
-
- TestModel(QObject *parent=0) : QAbstractListModel(parent) {
- QHash<int, QByteArray> roles;
- roles[Name] = "name";
- roles[Number] = "number";
- setRoleNames(roles);
- }
-
- int rowCount(const QModelIndex &parent=QModelIndex()) const { return list.count(); }
- QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) 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 count() const { return rowCount(); }
- QString name(int index) const { return list.at(index).first; }
- QString number(int index) const { return list.at(index).second; }
-
- void addItem(const QString &name, const QString &number) {
- emit beginInsertRows(QModelIndex(), list.count(), list.count());
- list.append(QPair<QString,QString>(name, number));
- emit endInsertRows();
- }
-
- void 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 removeItem(int index) {
- emit beginRemoveRows(QModelIndex(), index, index);
- list.removeAt(index);
- emit endRemoveRows();
- }
-
- void moveItem(int from, int to) {
- emit beginMoveRows(QModelIndex(), from, from, QModelIndex(), to);
- list.move(from, to);
- emit endMoveRows();
- }
-
- void modifyItem(int idx, const QString &name, const QString &number) {
- list[idx] = QPair<QString,QString>(name, number);
- emit dataChanged(index(idx,0), index(idx,0));
- }
-
-private:
- QList<QPair<QString,QString> > list;
-};
-
-
-tst_QmlGraphicsRepeater::tst_QmlGraphicsRepeater()
-{
-}
-
-void tst_QmlGraphicsRepeater::numberModel()
-{
- QmlView *canvas = createView(SRCDIR "/data/intmodel.qml");
-
- QmlContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testData", 5);
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
-
- canvas->execute();
- qApp->processEvents();
-
- QmlGraphicsRepeater *repeater = findItem<QmlGraphicsRepeater>(canvas->rootObject(), "repeater");
- QVERIFY(repeater != 0);
- QCOMPARE(repeater->parentItem()->childItems().count(), 5+1);
-
- QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
- QVERIFY(testObject->error() == false);
-
- delete canvas;
-}
-
-void tst_QmlGraphicsRepeater::objectList()
-{
- QmlView *canvas = createView(SRCDIR "/data/objlist.qml");
-
- QObjectList data;
- for(int i=0; i<100; i++){
- data << new QObject();
- data.back()->setProperty("idx", i);
- }
-
- QmlContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testData", QVariant::fromValue(data));
-
- canvas->execute();
- qApp->processEvents();
-
- QmlGraphicsRepeater *repeater = findItem<QmlGraphicsRepeater>(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);
-}
-
-/*
-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_QmlGraphicsRepeater::stringList()
-{
- QmlView *canvas = createView(SRCDIR "/data/repeater.qml");
-
- QStringList data;
- data << "One";
- data << "Two";
- data << "Three";
- data << "Four";
-
- QmlContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testData", data);
-
- canvas->execute();
- qApp->processEvents();
-
- QmlGraphicsRepeater *repeater = findItem<QmlGraphicsRepeater>(canvas->rootObject(), "repeater");
- QVERIFY(repeater != 0);
-
- QmlGraphicsItem *container = findItem<QmlGraphicsItem>(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) {
- QmlGraphicsText *name = qobject_cast<QmlGraphicsText*>(container->childItems().at(i));
- QVERIFY(name != 0);
- QCOMPARE(name->text(), QLatin1String("Zero"));
- } else if (i == container->childItems().count() - 2) {
- // The repeater itself
- QmlGraphicsRepeater *rep = qobject_cast<QmlGraphicsRepeater*>(container->childItems().at(i));
- QCOMPARE(rep, repeater);
- saw_repeater = true;
- continue;
- } else if (i == container->childItems().count() - 1) {
- QmlGraphicsText *name = qobject_cast<QmlGraphicsText*>(container->childItems().at(i));
- QVERIFY(name != 0);
- QCOMPARE(name->text(), QLatin1String("Last"));
- } else {
- QmlGraphicsText *name = qobject_cast<QmlGraphicsText*>(container->childItems().at(i));
- QVERIFY(name != 0);
- QCOMPARE(name->text(), data.at(i-1));
- }
- }
- QVERIFY(saw_repeater);
-
- delete canvas;
-}
-
-void tst_QmlGraphicsRepeater::dataModel()
-{
- QmlView *canvas = createView(SRCDIR "/data/repeater2.qml");
- QmlContext *ctxt = canvas->rootContext();
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
-
- TestModel testModel;
- testModel.addItem("one", "1");
- testModel.addItem("two", "2");
- testModel.addItem("three", "3");
-
- ctxt->setContextProperty("testData", &testModel);
-
- canvas->execute();
- qApp->processEvents();
-
- QmlGraphicsRepeater *repeater = findItem<QmlGraphicsRepeater>(canvas->rootObject(), "repeater");
- QVERIFY(repeater != 0);
-
- QmlGraphicsItem *container = findItem<QmlGraphicsItem>(canvas->rootObject(), "container");
- QVERIFY(container != 0);
-
- QCOMPARE(container->childItems().count(), 4);
-
- testModel.addItem("four", "4");
- QCOMPARE(container->childItems().count(), 5);
-
- testModel.removeItem(2);
- QCOMPARE(container->childItems().count(), 4);
-}
-
-void tst_QmlGraphicsRepeater::itemModel()
-{
- QmlView *canvas = createView(SRCDIR "/data/itemlist.qml");
- QmlContext *ctxt = canvas->rootContext();
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
-
- canvas->execute();
- qApp->processEvents();
-
- QmlGraphicsRepeater *repeater = findItem<QmlGraphicsRepeater>(canvas->rootObject(), "repeater");
- QVERIFY(repeater != 0);
-
- QmlGraphicsItem *container = findItem<QmlGraphicsItem>(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);
-
- delete canvas;
-}
-
-void tst_QmlGraphicsRepeater::properties()
-{
- QmlEngine engine;
- QmlComponent component(&engine, TEST_FILE("/properties.qml"));
-
- QmlGraphicsItem *rootObject = qobject_cast<QmlGraphicsItem*>(component.create());
- QVERIFY(rootObject);
-
- QmlGraphicsRepeater *repeater = findItem<QmlGraphicsRepeater>(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()));
-
- QmlComponent rectComponent(&engine);
- rectComponent.setData("import Qt 4.6; Rectangle {}", QUrl::fromLocalFile(""));
-
- repeater->setDelegate(&rectComponent);
- QCOMPARE(delegateSpy.count(),1);
- repeater->setDelegate(&rectComponent);
- QCOMPARE(delegateSpy.count(),1);
-}
-
-QmlView *tst_QmlGraphicsRepeater::createView(const QString &filename)
-{
- QmlView *canvas = new QmlView(0);
- canvas->setFixedSize(240,320);
-
- canvas->setSource(QUrl::fromLocalFile(filename));
-
- return canvas;
-}
-
-template<typename T>
-T *tst_QmlGraphicsRepeater::findItem(QGraphicsObject *parent, const QString &objectName)
-{
- const QMetaObject &mo = T::staticMetaObject;
- if (mo.cast(parent) && (objectName.isEmpty() || parent->objectName() == objectName))
- return static_cast<T*>(parent);
- for (int i = 0; i < parent->childItems().count(); ++i) {
- QmlGraphicsItem *child = qobject_cast<QmlGraphicsItem*>(parent->childItems().at(i));
- if (!child)
- continue;
- QmlGraphicsItem *item = findItem<T>(child, objectName);
- if (item)
- return static_cast<T*>(item);
- }
-
- return 0;
-}
-
-QTEST_MAIN(tst_QmlGraphicsRepeater)
-
-#include "tst_qmlgraphicsrepeater.moc"
diff --git a/tests/auto/declarative/qmlgraphicstext/qmlgraphicstext.pro b/tests/auto/declarative/qmlgraphicstext/qmlgraphicstext.pro
deleted file mode 100644
index 1d8c59f..0000000
--- a/tests/auto/declarative/qmlgraphicstext/qmlgraphicstext.pro
+++ /dev/null
@@ -1,5 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative gui
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qmlgraphicstext.cpp
diff --git a/tests/auto/declarative/qmlgraphicstext/tst_qmlgraphicstext.cpp b/tests/auto/declarative/qmlgraphicstext/tst_qmlgraphicstext.cpp
deleted file mode 100644
index 2c1e09b..0000000
--- a/tests/auto/declarative/qmlgraphicstext/tst_qmlgraphicstext.cpp
+++ /dev/null
@@ -1,844 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QTextDocument>
-#include <QtDeclarative/qmlengine.h>
-#include <QtDeclarative/qmlcomponent.h>
-#include <private/qmlgraphicstext_p.h>
-#include <private/qmlvaluetype_p.h>
-#include <QFontMetrics>
-#include <QGraphicsSceneMouseEvent>
-#include <qmath.h>
-
-class tst_qmlgraphicstext : public QObject
-
-{
- Q_OBJECT
-public:
- tst_qmlgraphicstext();
-
-private slots:
- void text();
- void width();
- void wrap();
- void elide();
- void textFormat();
-
- // ### these tests may be trivial
- void horizontalAlignment();
- void verticalAlignment();
- void font();
- void style();
- void color();
- void smooth();
-
- // QmlFontValueType
- void weight();
- void underline();
- void overline();
- void strikeout();
- void capitalization();
- void letterSpacing();
- void wordSpacing();
-
- void clickLink();
-
-private:
- QStringList standard;
- QStringList richText;
-
- QStringList horizontalAlignmentmentStrings;
- QStringList verticalAlignmentmentStrings;
-
- QList<Qt::Alignment> verticalAlignmentments;
- QList<Qt::Alignment> horizontalAlignmentments;
-
- QStringList styleStrings;
- QList<QmlGraphicsText::TextStyle> styles;
-
- QStringList colorStrings;
-
- QmlEngine engine;
-};
-
-tst_qmlgraphicstext::tst_qmlgraphicstext()
-{
- 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 << QmlGraphicsText::Normal
- << QmlGraphicsText::Outline
- << QmlGraphicsText::Raised
- << QmlGraphicsText::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";
- //
-}
-
-void tst_qmlgraphicstext::text()
-{
- {
- QmlComponent textComponent(&engine);
- textComponent.setData("import Qt 4.6\nText { text: \"\" }", QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(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 Qt 4.6\nText { text: \"" + standard.at(i) + "\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
-
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->text(), standard.at(i));
- QVERIFY(textObject->width() > 0);
- }
-
- for (int i = 0; i < richText.size(); i++)
- {
- QString componentStr = "import Qt 4.6\nText { text: \"" + richText.at(i) + "\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QString expected = richText.at(i);
- QCOMPARE(textObject->text(), expected.replace("\\\"", "\""));
- QVERIFY(textObject->width() > 0);
- }
-}
-
-void tst_qmlgraphicstext::width()
-{
- // uses Font metrics to find the width for standard and document to find the width for rich
- {
- QmlComponent textComponent(&engine);
- textComponent.setData("import Qt 4.6\nText { text: \"\" }", QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->width(), 0.);
- }
-
- for (int i = 0; i < standard.size(); i++)
- {
- QVERIFY(!Qt::mightBeRichText(standard.at(i))); // self-test
-
- QFont f;
- QFontMetricsF fm(f);
- qreal metricWidth = fm.size(Qt::TextExpandTabs && Qt::TextShowMnemonic, standard.at(i)).width();
- metricWidth = qCeil(metricWidth);
-
- QString componentStr = "import Qt 4.6\nText { text: \"" + standard.at(i) + "\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->width(), qreal(metricWidth));
- QVERIFY(textObject->textFormat() == QmlGraphicsText::AutoText); // setting text doesn't change format
- }
-
- for (int i = 0; i < richText.size(); i++)
- {
- QVERIFY(Qt::mightBeRichText(richText.at(i))); // self-test
-
- QTextDocument document;
- document.setHtml(richText.at(i));
- document.setDocumentMargin(0);
-
- int documentWidth = document.idealWidth();
-
- QString componentStr = "import Qt 4.6\nText { text: \"" + richText.at(i) + "\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->width(), qreal(documentWidth));
- QVERIFY(textObject->textFormat() == QmlGraphicsText::AutoText); // setting text doesn't change format
- }
-}
-
-void tst_qmlgraphicstext::wrap()
-{
- int textHeight = 0;
- // for specified width and wrap set true
- {
- QmlComponent textComponent(&engine);
- textComponent.setData("import Qt 4.6\nText { text: \"Hello\"; wrap: true; width: 300 }", QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
- textHeight = textObject->height();
-
- QVERIFY(textObject != 0);
- QVERIFY(textObject->wrap() == true);
- QCOMPARE(textObject->width(), 300.);
- }
-
- for (int i = 0; i < standard.size(); i++)
- {
- QString componentStr = "import Qt 4.6\nText { wrap: true; width: 30; text: \"" + standard.at(i) + "\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->width(), 30.);
- QVERIFY(textObject->height() > textHeight);
-
- int oldHeight = textObject->height();
- textObject->setWidth(100);
- QVERIFY(textObject->height() < oldHeight);
- }
-
- for (int i = 0; i < richText.size(); i++)
- {
- QString componentStr = "import Qt 4.6\nText { wrap: true; width: 30; text: \"" + richText.at(i) + "\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->width(), 30.);
- QVERIFY(textObject->height() > textHeight);
- }
-
-}
-
-void tst_qmlgraphicstext::elide()
-{
- for (QmlGraphicsText::TextElideMode m = QmlGraphicsText::ElideLeft; m<=QmlGraphicsText::ElideNone; m=QmlGraphicsText::TextElideMode(int(m)+1)) {
- const char* elidename[]={"ElideLeft", "ElideRight", "ElideMiddle", "ElideNone"};
- QString elide = "elide: Text." + QString(elidename[int(m)]) + ";";
-
- // XXX Poor coverage.
-
- {
- QmlComponent textComponent(&engine);
- textComponent.setData(("import Qt 4.6\nText { text: \"\"; "+elide+" width: 100 }").toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QCOMPARE(textObject->elideMode(), m);
- QCOMPARE(textObject->width(), 100.);
- }
-
- for (int i = 0; i < standard.size(); i++)
- {
- QString componentStr = "import Qt 4.6\nText { "+elide+" width: 100; text: \"" + standard.at(i) + "\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QCOMPARE(textObject->elideMode(), m);
- QCOMPARE(textObject->width(), 100.);
- }
-
- // richtext - does nothing
- for (int i = 0; i < richText.size(); i++)
- {
- QString componentStr = "import Qt 4.6\nText { "+elide+" width: 100; text: \"" + richText.at(i) + "\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QCOMPARE(textObject->elideMode(), m);
- QCOMPARE(textObject->width(), 100.);
- }
- }
-}
-
-void tst_qmlgraphicstext::textFormat()
-{
- {
- QmlComponent textComponent(&engine);
- textComponent.setData("import Qt 4.6\nText { text: \"Hello\"; textFormat: Text.RichText }", QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QVERIFY(textObject->textFormat() == QmlGraphicsText::RichText);
- }
- {
- QmlComponent textComponent(&engine);
- textComponent.setData("import Qt 4.6\nText { text: \"<b>Hello</b>\"; textFormat: Text.PlainText }", QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QVERIFY(textObject->textFormat() == QmlGraphicsText::PlainText);
- }
-}
-
-//the alignment tests may be trivial o.oa
-void tst_qmlgraphicstext::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 Qt 4.6\nText { horizontalAlignment: \"" + horizontalAlignmentmentStrings.at(j) + "\"; text: \"" + standard.at(i) + "\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QCOMPARE((int)textObject->hAlign(), (int)horizontalAlignmentments.at(j));
- }
- }
-
- for (int i = 0; i < richText.size(); i++)
- {
- for (int j=0; j < horizontalAlignmentmentStrings.size(); j++)
- {
- QString componentStr = "import Qt 4.6\nText { horizontalAlignment: \"" + horizontalAlignmentmentStrings.at(j) + "\"; text: \"" + richText.at(i) + "\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QCOMPARE((int)textObject->hAlign(), (int)horizontalAlignmentments.at(j));
- }
- }
-
-}
-
-void tst_qmlgraphicstext::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 Qt 4.6\nText { verticalAlignment: \"" + verticalAlignmentmentStrings.at(j) + "\"; text: \"" + standard.at(i) + "\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE((int)textObject->vAlign(), (int)verticalAlignmentments.at(j));
- }
- }
-
- for (int i = 0; i < richText.size(); i++)
- {
- for (int j=0; j < verticalAlignmentmentStrings.size(); j++)
- {
- QString componentStr = "import Qt 4.6\nText { verticalAlignment: \"" + verticalAlignmentmentStrings.at(j) + "\"; text: \"" + richText.at(i) + "\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE((int)textObject->vAlign(), (int)verticalAlignmentments.at(j));
- }
- }
-
-}
-
-void tst_qmlgraphicstext::font()
-{
- //test size, then bold, then italic, then family
- {
- QString componentStr = "import Qt 4.6\nText { font.pointSize: 40; text: \"Hello World\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QCOMPARE(textObject->font().pointSize(), 40);
- QCOMPARE(textObject->font().bold(), false);
- QCOMPARE(textObject->font().italic(), false);
- }
-
- {
- QString componentStr = "import Qt 4.6\nText { font.pixelSize: 40; text: \"Hello World\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QCOMPARE(textObject->font().pixelSize(), 40);
- QCOMPARE(textObject->font().bold(), false);
- QCOMPARE(textObject->font().italic(), false);
- }
-
- {
- QString componentStr = "import Qt 4.6\nText { font.bold: true; text: \"Hello World\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QCOMPARE(textObject->font().bold(), true);
- QCOMPARE(textObject->font().italic(), false);
- }
-
- {
- QString componentStr = "import Qt 4.6\nText { font.italic: true; text: \"Hello World\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QCOMPARE(textObject->font().italic(), true);
- QCOMPARE(textObject->font().bold(), false);
- }
-
- {
- QString componentStr = "import Qt 4.6\nText { font.family: \"Helvetica\"; text: \"Hello World\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QCOMPARE(textObject->font().family(), QString("Helvetica"));
- QCOMPARE(textObject->font().bold(), false);
- QCOMPARE(textObject->font().italic(), false);
- }
-
- {
- QString componentStr = "import Qt 4.6\nText { font.family: \"\"; text: \"Hello World\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QCOMPARE(textObject->font().family(), QString(""));
- }
-}
-
-void tst_qmlgraphicstext::style()
-{
- //test style
- for (int i = 0; i < styles.size(); i++)
- {
- QString componentStr = "import Qt 4.6\nText { style: \"" + styleStrings.at(i) + "\"; styleColor: \"white\"; text: \"Hello World\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QCOMPARE((int)textObject->style(), (int)styles.at(i));
- QCOMPARE(textObject->styleColor(), QColor("white"));
- }
-}
-
-void tst_qmlgraphicstext::color()
-{
- //test style
- for (int i = 0; i < colorStrings.size(); i++)
- {
- QString componentStr = "import Qt 4.6\nText { color: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QCOMPARE(textObject->color(), QColor(colorStrings.at(i)));
- QCOMPARE(textObject->styleColor(), QColor());
- }
-
- for (int i = 0; i < colorStrings.size(); i++)
- {
- QString componentStr = "import Qt 4.6\nText { styleColor: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QCOMPARE(textObject->styleColor(), QColor(colorStrings.at(i)));
- // default color to black?
- QCOMPARE(textObject->color(), QColor("black"));
- }
-
- for (int i = 0; i < colorStrings.size(); i++)
- {
- for (int j = 0; j < colorStrings.size(); j++)
- {
- QString componentStr = "import Qt 4.6\nText { color: \"" + colorStrings.at(i) + "\"; styleColor: \"" + colorStrings.at(j) + "\"; text: \"Hello World\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QCOMPARE(textObject->color(), QColor(colorStrings.at(i)));
- QCOMPARE(textObject->styleColor(), QColor(colorStrings.at(j)));
- }
- }
- {
- QString colorStr = "#AA001234";
- QColor testColor("#001234");
- testColor.setAlpha(170);
-
- QString componentStr = "import Qt 4.6\nText { color: \"" + colorStr + "\"; text: \"Hello World\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QCOMPARE(textObject->color(), testColor);
- }
-}
-
-void tst_qmlgraphicstext::smooth()
-{
- for (int i = 0; i < standard.size(); i++)
- {
- {
- QString componentStr = "import Qt 4.6\nText { smooth: true; text: \"" + standard.at(i) + "\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
- QCOMPARE(textObject->smooth(), true);
- }
- {
- QString componentStr = "import Qt 4.6\nText { text: \"" + standard.at(i) + "\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
- QCOMPARE(textObject->smooth(), false);
- }
- }
- for (int i = 0; i < richText.size(); i++)
- {
- {
- QString componentStr = "import Qt 4.6\nText { smooth: true; text: \"" + richText.at(i) + "\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
- QCOMPARE(textObject->smooth(), true);
- }
- {
- QString componentStr = "import Qt 4.6\nText { text: \"" + richText.at(i) + "\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
- QCOMPARE(textObject->smooth(), false);
- }
- }
-}
-
-void tst_qmlgraphicstext::weight()
-{
- {
- QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE((int)textObject->font().weight(), (int)QmlFontValueType::Normal);
- }
- {
- QString componentStr = "import Qt 4.6\nText { font.weight: \"Bold\"; text: \"Hello world!\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE((int)textObject->font().weight(), (int)QmlFontValueType::Bold);
- }
-}
-
-void tst_qmlgraphicstext::underline()
-{
- {
- QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->font().underline(), false);
- }
- {
- QString componentStr = "import Qt 4.6\nText { font.underline: true; text: \"Hello world!\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->font().underline(), true);
- }
-}
-
-void tst_qmlgraphicstext::overline()
-{
- {
- QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->font().overline(), false);
- }
- {
- QString componentStr = "import Qt 4.6\nText { font.overline: true; text: \"Hello world!\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->font().overline(), true);
- }
-}
-
-void tst_qmlgraphicstext::strikeout()
-{
- {
- QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->font().strikeOut(), false);
- }
- {
- QString componentStr = "import Qt 4.6\nText { font.strikeout: true; text: \"Hello world!\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->font().strikeOut(), true);
- }
-}
-
-void tst_qmlgraphicstext::capitalization()
-{
- {
- QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE((int)textObject->font().capitalization(), (int)QmlFontValueType::MixedCase);
- }
- {
- QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\"; font.capitalization: \"AllUppercase\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE((int)textObject->font().capitalization(), (int)QmlFontValueType::AllUppercase);
- }
- {
- QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\"; font.capitalization: \"AllLowercase\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE((int)textObject->font().capitalization(), (int)QmlFontValueType::AllLowercase);
- }
- {
- QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\"; font.capitalization: \"SmallCaps\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE((int)textObject->font().capitalization(), (int)QmlFontValueType::SmallCaps);
- }
- {
- QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\"; font.capitalization: \"Capitalize\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE((int)textObject->font().capitalization(), (int)QmlFontValueType::Capitalize);
- }
-}
-
-void tst_qmlgraphicstext::letterSpacing()
-{
- {
- QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->font().letterSpacing(), 0.0);
- }
- {
- QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\"; font.letterSpacing: -50 }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->font().letterSpacing(), -50.);
- }
- {
- QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\"; font.letterSpacing: 200 }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->font().letterSpacing(), 200.);
- }
-}
-
-void tst_qmlgraphicstext::wordSpacing()
-{
- {
- QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->font().wordSpacing(), 0.0);
- }
- {
- QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\"; font.wordSpacing: -50 }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->font().wordSpacing(), -50.);
- }
- {
- QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\"; font.wordSpacing: 200 }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->font().wordSpacing(), 200.);
- }
-}
-
-class EventSender : public QGraphicsItem
-{
-public:
- void sendEvent(QEvent *event) { sceneEvent(event); }
-};
-
-class LinkTest : public QObject
-{
- Q_OBJECT
-public:
- LinkTest() {}
-
- QString link;
-
-public slots:
- void linkClicked(QString l) { link = l; }
-};
-
-void tst_qmlgraphicstext::clickLink()
-{
- {
- QString componentStr = "import Qt 4.6\nText { text: \"<a href=\\\"http://qt.nokia.com\\\">Hello world!</a>\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
-
- LinkTest test;
- QObject::connect(textObject, SIGNAL(linkActivated(QString)), &test, SLOT(linkClicked(QString)));
-
- {
- QGraphicsSceneMouseEvent me(QEvent::GraphicsSceneMousePress);
- me.setPos(QPointF(textObject->x()/2, textObject->y()/2));
- me.setButton(Qt::LeftButton);
- static_cast<EventSender*>(static_cast<QGraphicsItem*>(textObject))->sendEvent(&me);
- }
-
- {
- QGraphicsSceneMouseEvent me(QEvent::GraphicsSceneMouseRelease);
- me.setPos(QPointF(textObject->x()/2, textObject->y()/2));
- me.setButton(Qt::LeftButton);
- static_cast<EventSender*>(static_cast<QGraphicsItem*>(textObject))->sendEvent(&me);
- }
-
- QCOMPARE(test.link, QLatin1String("http://qt.nokia.com"));
- }
-}
-
-QTEST_MAIN(tst_qmlgraphicstext)
-
-#include "tst_qmlgraphicstext.moc"
diff --git a/tests/auto/declarative/qmlgraphicstextedit/qmlgraphicstextedit.pro b/tests/auto/declarative/qmlgraphicstextedit/qmlgraphicstextedit.pro
deleted file mode 100644
index a129120..0000000
--- a/tests/auto/declarative/qmlgraphicstextedit/qmlgraphicstextedit.pro
+++ /dev/null
@@ -1,9 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative gui network
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qmlgraphicstextedit.cpp ../shared/testhttpserver.cpp
-HEADERS += ../shared/testhttpserver.h
-
-# Define SRCDIR equal to test's source directory
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmlgraphicstextedit/tst_qmlgraphicstextedit.cpp b/tests/auto/declarative/qmlgraphicstextedit/tst_qmlgraphicstextedit.cpp
deleted file mode 100644
index cc2f929..0000000
--- a/tests/auto/declarative/qmlgraphicstextedit/tst_qmlgraphicstextedit.cpp
+++ /dev/null
@@ -1,798 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include "../../../shared/util.h"
-#include "../shared/testhttpserver.h"
-#include <math.h>
-#include <QFile>
-#include <QTextDocument>
-#include <QtDeclarative/qmlengine.h>
-#include <QtDeclarative/qmlcontext.h>
-#include <QtDeclarative/qmlexpression.h>
-#include <QtDeclarative/qmlcomponent.h>
-#include <private/qmlgraphicstextedit_p.h>
-#include <QFontMetrics>
-#include <QmlView>
-#include <QStyle>
-#include <QInputContext>
-
-class tst_qmlgraphicstextedit : public QObject
-
-{
- Q_OBJECT
-public:
- tst_qmlgraphicstextedit();
-
-private slots:
- void text();
- void width();
- void wrap();
- void textFormat();
-
- // ### these tests may be trivial
- void hAlign();
- void vAlign();
- void font();
- void color();
- void textMargin();
- void persistentSelection();
- void focusOnPress();
- void selection();
- void inputMethodHints();
-
- void cursorDelegate();
- void delegateLoading();
- void navigation();
- void readOnly();
- void sendRequestSoftwareInputPanelEvent();
-
-private:
- void simulateKey(QmlView *, int key);
- QmlView *createView(const QString &filename);
-
- QStringList standard;
- QStringList richText;
-
- QStringList hAlignmentStrings;
- QStringList vAlignmentStrings;
-
- QList<Qt::Alignment> vAlignments;
- QList<Qt::Alignment> hAlignments;
-
- QStringList colorStrings;
-
- QmlEngine engine;
-};
-
-tst_qmlgraphicstextedit::tst_qmlgraphicstextedit()
-{
- 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>";
-
- 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_qmlgraphicstextedit::text()
-{
- {
- QmlComponent texteditComponent(&engine);
- texteditComponent.setData("import Qt 4.6\nTextEdit { text: \"\" }", QUrl());
- QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->text(), QString(""));
- }
-
- for (int i = 0; i < standard.size(); i++)
- {
- QString componentStr = "import Qt 4.6\nTextEdit { text: \"" + standard.at(i) + "\" }";
- QmlComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->text(), standard.at(i));
- }
-
- for (int i = 0; i < richText.size(); i++)
- {
- QString componentStr = "import Qt 4.6\nTextEdit { text: \"" + richText.at(i) + "\" }";
- QmlComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(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());
- }
-}
-
-void tst_qmlgraphicstextedit::width()
-{
- // uses Font metrics to find the width for standard and document to find the width for rich
- {
- QmlComponent texteditComponent(&engine);
- texteditComponent.setData("import Qt 4.6\nTextEdit { text: \"\" }", QUrl());
- QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->width(), 1.);//+1 for cursor
- }
-
- for (int i = 0; i < standard.size(); i++)
- {
- QFont f;
- QFontMetricsF fm(f);
- qreal metricWidth = fm.size(Qt::TextExpandTabs && Qt::TextShowMnemonic, standard.at(i)).width();
- metricWidth = floor(metricWidth);
-
- QString componentStr = "import Qt 4.6\nTextEdit { text: \"" + standard.at(i) + "\" }";
- QmlComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->width(), qreal(metricWidth + 1 + 3));//+3 is the current way of accounting for space between cursor and last character.
- }
-
- for (int i = 0; i < richText.size(); i++)
- {
- QTextDocument document;
- document.setHtml(richText.at(i));
- document.setDocumentMargin(0);
-
- int documentWidth = document.idealWidth();
-
- QString componentStr = "import Qt 4.6\nTextEdit { text: \"" + richText.at(i) + "\" }";
- QmlComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->width(), qreal(documentWidth + 1 + 3));
- }
-}
-
-void tst_qmlgraphicstextedit::wrap()
-{
- // for specified width and wrap set true
- {
- QmlComponent texteditComponent(&engine);
- texteditComponent.setData("import Qt 4.6\nTextEdit { text: \"\"; wrap: true; width: 300 }", QUrl());
- QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->width(), 300.);
- }
-
- for (int i = 0; i < standard.size(); i++)
- {
- QString componentStr = "import Qt 4.6\nTextEdit { wrap: true; width: 300; text: \"" + standard.at(i) + "\" }";
- QmlComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->width(), 300.);
- }
-
- for (int i = 0; i < richText.size(); i++)
- {
- QString componentStr = "import Qt 4.6\nTextEdit { wrap: true; width: 300; text: \"" + richText.at(i) + "\" }";
- QmlComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->width(), 300.);
- }
-
-}
-
-void tst_qmlgraphicstextedit::textFormat()
-{
- {
- QmlComponent textComponent(&engine);
- textComponent.setData("import Qt 4.6\nTextEdit { text: \"Hello\"; textFormat: Text.RichText }", QUrl::fromLocalFile(""));
- QmlGraphicsTextEdit *textObject = qobject_cast<QmlGraphicsTextEdit*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QVERIFY(textObject->textFormat() == QmlGraphicsTextEdit::RichText);
- }
- {
- QmlComponent textComponent(&engine);
- textComponent.setData("import Qt 4.6\nTextEdit { text: \"<b>Hello</b>\"; textFormat: Text.PlainText }", QUrl::fromLocalFile(""));
- QmlGraphicsTextEdit *textObject = qobject_cast<QmlGraphicsTextEdit*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QVERIFY(textObject->textFormat() == QmlGraphicsTextEdit::PlainText);
- }
-}
-
-//the alignment tests may be trivial o.oa
-void tst_qmlgraphicstextedit::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 Qt 4.6\nTextEdit { horizontalAlignment: \"" + hAlignmentStrings.at(j) + "\"; text: \"" + standard.at(i) + "\" }";
- QmlComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(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 Qt 4.6\nTextEdit { horizontalAlignment: \"" + hAlignmentStrings.at(j) + "\"; text: \"" + richText.at(i) + "\" }";
- QmlComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE((int)textEditObject->hAlign(), (int)hAlignments.at(j));
- }
- }
-
-}
-
-void tst_qmlgraphicstextedit::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 Qt 4.6\nTextEdit { verticalAlignment: \"" + vAlignmentStrings.at(j) + "\"; text: \"" + standard.at(i) + "\" }";
- QmlComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(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 Qt 4.6\nTextEdit { verticalAlignment: \"" + vAlignmentStrings.at(j) + "\"; text: \"" + richText.at(i) + "\" }";
- QmlComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE((int)textEditObject->vAlign(), (int)vAlignments.at(j));
- }
- }
-
-}
-
-void tst_qmlgraphicstextedit::font()
-{
- //test size, then bold, then italic, then family
- {
- QString componentStr = "import Qt 4.6\nTextEdit { font.pointSize: 40; text: \"Hello World\" }";
- QmlComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->font().pointSize(), 40);
- QCOMPARE(textEditObject->font().bold(), false);
- QCOMPARE(textEditObject->font().italic(), false);
- }
-
- {
- QString componentStr = "import Qt 4.6\nTextEdit { font.bold: true; text: \"Hello World\" }";
- QmlComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->font().bold(), true);
- QCOMPARE(textEditObject->font().italic(), false);
- }
-
- {
- QString componentStr = "import Qt 4.6\nTextEdit { font.italic: true; text: \"Hello World\" }";
- QmlComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->font().italic(), true);
- QCOMPARE(textEditObject->font().bold(), false);
- }
-
- {
- QString componentStr = "import Qt 4.6\nTextEdit { font.family: \"Helvetica\"; text: \"Hello World\" }";
- QmlComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->font().family(), QString("Helvetica"));
- QCOMPARE(textEditObject->font().bold(), false);
- QCOMPARE(textEditObject->font().italic(), false);
- }
-
- {
- QString componentStr = "import Qt 4.6\nTextEdit { font.family: \"\"; text: \"Hello World\" }";
- QmlComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->font().family(), QString(""));
- }
-}
-
-void tst_qmlgraphicstextedit::color()
-{
- //test normal
- for (int i = 0; i < colorStrings.size(); i++)
- {
- QString componentStr = "import Qt 4.6\nTextEdit { color: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
- QmlComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(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 Qt 4.6\nTextEdit { selectionColor: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
- QmlComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(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 Qt 4.6\nTextEdit { selectedTextColor: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
- QmlComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(texteditComponent.create());
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->selectedTextColor(), QColor(colorStrings.at(i)));
- }
-
- {
- QString colorStr = "#AA001234";
- QColor testColor("#001234");
- testColor.setAlpha(170);
-
- QString componentStr = "import Qt 4.6\nTextEdit { color: \"" + colorStr + "\"; text: \"Hello World\" }";
- QmlComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->color(), testColor);
- }
-}
-
-void tst_qmlgraphicstextedit::textMargin()
-{
- for(qreal i=0; i<=10; i+=0.3){
- QString componentStr = "import Qt 4.6\nTextEdit { textMargin: " + QString::number(i) + "; text: \"Hello World\" }";
- QmlComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(texteditComponent.create());
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->textMargin(), i);
- }
-}
-
-void tst_qmlgraphicstextedit::persistentSelection()
-{
- {
- QString componentStr = "import Qt 4.6\nTextEdit { persistentSelection: true; text: \"Hello World\" }";
- QmlComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(texteditComponent.create());
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->persistentSelection(), true);
- }
-
- {
- QString componentStr = "import Qt 4.6\nTextEdit { persistentSelection: false; text: \"Hello World\" }";
- QmlComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(texteditComponent.create());
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->persistentSelection(), false);
- }
-}
-
-void tst_qmlgraphicstextedit::focusOnPress()
-{
- {
- QString componentStr = "import Qt 4.6\nTextEdit { focusOnPress: true; text: \"Hello World\" }";
- QmlComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(texteditComponent.create());
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->focusOnPress(), true);
- }
-
- {
- QString componentStr = "import Qt 4.6\nTextEdit { focusOnPress: false; text: \"Hello World\" }";
- QmlComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(texteditComponent.create());
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->focusOnPress(), false);
- }
-}
-
-void tst_qmlgraphicstextedit::selection()
-{
- QString testStr = standard[0];//TODO: What should happen for multiline/rich text?
- QString componentStr = "import Qt 4.6\nTextEdit { text: \""+ testStr +"\"; }";
- QmlComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(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());
-
- //Test selection
- for(int i=0; i<= testStr.size(); i++) {
- textEditObject->setSelectionEnd(i);
- QCOMPARE(testStr.mid(0,i), textEditObject->selectedText());
- }
- for(int i=0; i<= testStr.size(); i++) {
- textEditObject->setSelectionStart(i);
- 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());
-
- for(int i=0; i< testStr.size(); i++) {
- textEditObject->setSelectionStart(i);
- QCOMPARE(textEditObject->selectionEnd(), i);
- QCOMPARE(testStr.mid(i,0), textEditObject->selectedText());
- textEditObject->setSelectionEnd(i+1);
- QCOMPARE(textEditObject->selectionStart(), i);
- QCOMPARE(testStr.mid(i,1), textEditObject->selectedText());
- }
-
- for(int i= testStr.size() - 1; i>0; i--) {
- textEditObject->setSelectionEnd(i);
- QCOMPARE(testStr.mid(i,0), textEditObject->selectedText());
- textEditObject->setSelectionStart(i-1);
- QCOMPARE(testStr.mid(i-1,1), textEditObject->selectedText());
- }
-
- //Test Error Ignoring behaviour
- textEditObject->setCursorPosition(0);
- QVERIFY(textEditObject->selectedText().isNull());
- textEditObject->setSelectionStart(-10);
- QVERIFY(textEditObject->selectedText().isNull());
- textEditObject->setSelectionStart(100);
- QVERIFY(textEditObject->selectedText().isNull());
- textEditObject->setSelectionEnd(-10);
- QVERIFY(textEditObject->selectedText().isNull());
- textEditObject->setSelectionEnd(100);
- QVERIFY(textEditObject->selectedText().isNull());
- textEditObject->setSelectionStart(0);
- textEditObject->setSelectionEnd(10);
- QVERIFY(textEditObject->selectedText().size() == 10);
- textEditObject->setSelectionStart(-10);
- QVERIFY(textEditObject->selectedText().size() == 10);
- textEditObject->setSelectionStart(100);
- QVERIFY(textEditObject->selectedText().size() == 10);
- textEditObject->setSelectionEnd(-10);
- QVERIFY(textEditObject->selectedText().size() == 10);
- textEditObject->setSelectionEnd(100);
- QVERIFY(textEditObject->selectedText().size() == 10);
-}
-
-void tst_qmlgraphicstextedit::inputMethodHints()
-{
- QmlView *canvas = createView(SRCDIR "/data/inputmethodhints.qml");
- canvas->execute();
- canvas->show();
- canvas->setFocus();
-
- QVERIFY(canvas->rootObject() != 0);
- QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit *>(canvas->rootObject());
- QVERIFY(textEditObject != 0);
- QVERIFY(textEditObject->inputMethodHints() & Qt::ImhNoPredictiveText);
- textEditObject->setInputMethodHints(Qt::ImhUppercaseOnly);
- QVERIFY(textEditObject->inputMethodHints() & Qt::ImhUppercaseOnly);
-}
-
-void tst_qmlgraphicstextedit::cursorDelegate()
-{
- QmlView* view = createView(SRCDIR "/data/cursorTest.qml");
- view->execute();
- view->show();
- view->setFocus();
- QmlGraphicsTextEdit *textEditObject = view->rootObject()->findChild<QmlGraphicsTextEdit*>("textEditObject");
- QVERIFY(textEditObject != 0);
- QVERIFY(textEditObject->findChild<QmlGraphicsItem*>("cursorInstance"));
- //Test Delegate gets created
- textEditObject->setFocus(true);
- QmlGraphicsItem* delegateObject = textEditObject->findChild<QmlGraphicsItem*>("cursorInstance");
- QVERIFY(delegateObject);
- //Test Delegate gets moved
- for(int i=0; i<= textEditObject->text().length(); i++){
- textEditObject->setCursorPosition(i);
- QCOMPARE(textEditObject->cursorRect().x(), qRound(delegateObject->x()));
- QCOMPARE(textEditObject->cursorRect().y(), qRound(delegateObject->y()));
- }
- textEditObject->setCursorPosition(0);
- QCOMPARE(textEditObject->cursorRect().x(), qRound(delegateObject->x()));
- QCOMPARE(textEditObject->cursorRect().y(), qRound(delegateObject->y()));
- //Test Delegate gets deleted
- textEditObject->setCursorDelegate(0);
- QVERIFY(!textEditObject->findChild<QmlGraphicsItem*>("cursorInstance"));
-}
-
-void tst_qmlgraphicstextedit::delegateLoading()
-{
- TestHTTPServer server(42332);
- server.serveDirectory(SRCDIR "/data/httpfail", TestHTTPServer::Disconnect);
- server.serveDirectory(SRCDIR "/data/httpslow", TestHTTPServer::Delay);
- server.serveDirectory(SRCDIR "/data/http");
- QmlView* view = new QmlView(0);
- view->setSource(QUrl("http://localhost:42332/cursorHttpTestPass.qml"));
- view->execute();
- view->show();
- view->setFocus();
- QTRY_VERIFY(view->rootObject());//Wait for loading to finish.
- QmlGraphicsTextEdit *textEditObject = view->rootObject()->findChild<QmlGraphicsTextEdit*>("textEditObject");
- // view->rootObject()->dumpObjectTree();
- QVERIFY(textEditObject != 0);
- textEditObject->setFocus(true);
- QmlGraphicsItem *delegate;
- delegate = view->rootObject()->findChild<QmlGraphicsItem*>("delegateOkay");
- QVERIFY(delegate);
- delegate = view->rootObject()->findChild<QmlGraphicsItem*>("delegateSlow");
- QVERIFY(delegate);
- view->setSource(QUrl("http://localhost:42332/cursorHttpTestFail1.qml"));
- view->execute();
- view->show();
- view->setFocus();
- QTRY_VERIFY(!view->rootObject()); // there is fail item inside this test
- view->setSource(QUrl("http://localhost:42332/cursorHttpTestFail2.qml"));
- view->execute();
- view->show();
- view->setFocus();
- QTRY_VERIFY(!view->rootObject()); // there is fail item inside this test
- //ErrorB should get a component which is ready but component.create() returns null
- //Not sure how to accomplish this with QmlGraphicsTextEdits cursor delegate
- //###This could be a case of overzealous defensive programming
- //delegate = view->rootObject()->findChild<QmlGraphicsItem*>("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_qmlgraphicstextedit::navigation()
-{
- QmlView *canvas = createView(SRCDIR "/data/navigation.qml");
- canvas->execute();
- canvas->show();
- canvas->setFocus();
-
- QVERIFY(canvas->rootObject() != 0);
-
- QmlGraphicsItem *input = qobject_cast<QmlGraphicsItem *>(qvariant_cast<QObject *>(canvas->rootObject()->property("myInput")));
-
- QVERIFY(input != 0);
- QTRY_VERIFY(input->hasFocus() == true);
- simulateKey(canvas, Qt::Key_Left);
- QVERIFY(input->hasFocus() == false);
- simulateKey(canvas, Qt::Key_Right);
- QVERIFY(input->hasFocus() == true);
- simulateKey(canvas, Qt::Key_Right);
- QVERIFY(input->hasFocus() == false);
- simulateKey(canvas, Qt::Key_Left);
- QVERIFY(input->hasFocus() == true);
-}
-
-void tst_qmlgraphicstextedit::readOnly()
-{
- QmlView *canvas = createView(SRCDIR "/data/readOnly.qml");
- canvas->execute();
- canvas->show();
- canvas->setFocus();
-
- QVERIFY(canvas->rootObject() != 0);
-
- QmlGraphicsTextEdit *edit = qobject_cast<QmlGraphicsTextEdit *>(qvariant_cast<QObject *>(canvas->rootObject()->property("myInput")));
-
- QVERIFY(edit != 0);
- QTRY_VERIFY(edit->hasFocus() == 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);
-}
-
-void tst_qmlgraphicstextedit::simulateKey(QmlView *view, int key)
-{
- QKeyEvent press(QKeyEvent::KeyPress, key, 0);
- QKeyEvent release(QKeyEvent::KeyRelease, key, 0);
-
- QApplication::sendEvent(view, &press);
- QApplication::sendEvent(view, &release);
-}
-
-QmlView *tst_qmlgraphicstextedit::createView(const QString &filename)
-{
- QmlView *canvas = new QmlView(0);
-
- canvas->setSource(QUrl::fromLocalFile(filename));
- return canvas;
-}
-
-class MyInputContext : public QInputContext
-{
-public:
- MyInputContext() : softwareInputPanelEventReceived(false) {}
- ~MyInputContext() {}
-
- QString identifierName() { return QString(); }
- QString language() { return QString(); }
-
- void reset() {}
-
- bool isComposing() const { return false; }
-
- bool filterEvent( const QEvent *event )
- {
- if (event->type() == QEvent::RequestSoftwareInputPanel)
- softwareInputPanelEventReceived = true;
- return QInputContext::filterEvent(event);
- }
- bool softwareInputPanelEventReceived;
-};
-
-void tst_qmlgraphicstextedit::sendRequestSoftwareInputPanelEvent()
-{
- QGraphicsScene scene;
- QGraphicsView view(&scene);
- MyInputContext ic;
- view.viewport()->setInputContext(&ic);
- QStyle::RequestSoftwareInputPanel behavior = QStyle::RequestSoftwareInputPanel(
- view.style()->styleHint(QStyle::SH_RequestSoftwareInputPanel));
- if ((behavior != QStyle::RSIP_OnMouseClick))
- QSKIP("This test need to have a style with RSIP_OnMouseClick", SkipSingle);
- QmlGraphicsTextEdit edit;
- edit.setText("Hello world");
- edit.setPos(0, 0);
- scene.addItem(&edit);
- view.show();
- qApp->setAutoSipEnabled(true);
- QApplication::setActiveWindow(&view);
- QTest::qWaitForWindowShown(&view);
- QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&view));
- QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(edit.scenePos()));
- QApplication::processEvents();
- QCOMPARE(ic.softwareInputPanelEventReceived, true);
-}
-QTEST_MAIN(tst_qmlgraphicstextedit)
-
-#include "tst_qmlgraphicstextedit.moc"
diff --git a/tests/auto/declarative/qmlgraphicstextinput/qmlgraphicstextinput.pro b/tests/auto/declarative/qmlgraphicstextinput/qmlgraphicstextinput.pro
deleted file mode 100644
index fd75fec..0000000
--- a/tests/auto/declarative/qmlgraphicstextinput/qmlgraphicstextinput.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative gui
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qmlgraphicstextinput.cpp
-
-# Define SRCDIR equal to test's source directory
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmlgraphicstextinput/tst_qmlgraphicstextinput.cpp b/tests/auto/declarative/qmlgraphicstextinput/tst_qmlgraphicstextinput.cpp
deleted file mode 100644
index 8b45fc7..0000000
--- a/tests/auto/declarative/qmlgraphicstextinput/tst_qmlgraphicstextinput.cpp
+++ /dev/null
@@ -1,663 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include "../../../shared/util.h"
-#include <QtDeclarative/qmlengine.h>
-#include <QFile>
-#include <QtDeclarative/qmlview.h>
-#include <private/qmlgraphicstextinput_p.h>
-#include <QDebug>
-#include <QStyle>
-#include <QInputContext>
-
-class tst_qmlgraphicstextinput : public QObject
-
-{
- Q_OBJECT
-public:
- tst_qmlgraphicstextinput();
-
-private slots:
- void text();
- void width();
- void font();
- void color();
- void selection();
-
- void maxLength();
- void masks();
- void validators();
- void inputMethodHints();
-
- void cursorDelegate();
- void navigation();
- void readOnly();
-
- void sendRequestSoftwareInputPanelEvent();
-
-private:
- void simulateKey(QmlView *, int key);
- QmlView *createView(const QString &filename);
-
- QmlEngine engine;
- QStringList standard;
- QStringList colorStrings;
-};
-
-tst_qmlgraphicstextinput::tst_qmlgraphicstextinput()
-{
- standard << "the quick brown fox jumped over the lazy dog"
- << "It's supercalifragisiticexpialidocious!"
- << "Hello, world!";
-
- colorStrings << "aliceblue"
- << "antiquewhite"
- << "aqua"
- << "darkkhaki"
- << "darkolivegreen"
- << "dimgray"
- << "palevioletred"
- << "lightsteelblue"
- << "#000000"
- << "#AAAAAA"
- << "#FFFFFF"
- << "#2AC05F";
-}
-
-void tst_qmlgraphicstextinput::text()
-{
- {
- QmlComponent textinputComponent(&engine);
- textinputComponent.setData("import Qt 4.6\nTextInput { text: \"\" }", QUrl());
- QmlGraphicsTextInput *textinputObject = qobject_cast<QmlGraphicsTextInput*>(textinputComponent.create());
-
- QVERIFY(textinputObject != 0);
- QCOMPARE(textinputObject->text(), QString(""));
- }
-
- for (int i = 0; i < standard.size(); i++)
- {
- QString componentStr = "import Qt 4.6\nTextInput { text: \"" + standard.at(i) + "\" }";
- QmlComponent textinputComponent(&engine);
- textinputComponent.setData(componentStr.toLatin1(), QUrl());
- QmlGraphicsTextInput *textinputObject = qobject_cast<QmlGraphicsTextInput*>(textinputComponent.create());
-
- QVERIFY(textinputObject != 0);
- QCOMPARE(textinputObject->text(), standard.at(i));
- }
-
-}
-
-void tst_qmlgraphicstextinput::width()
-{
- // uses Font metrics to find the width for standard
- {
- QmlComponent textinputComponent(&engine);
- textinputComponent.setData("import Qt 4.6\nTextInput { text: \"\" }", QUrl());
- QmlGraphicsTextInput *textinputObject = qobject_cast<QmlGraphicsTextInput*>(textinputComponent.create());
-
- QVERIFY(textinputObject != 0);
- QCOMPARE(textinputObject->width(), 1.);//1 for the cursor
- }
-
- for (int i = 0; i < standard.size(); i++)
- {
- QFont f;
- QFontMetricsF fm(f);
- qreal metricWidth = fm.width(standard.at(i));
-
- QString componentStr = "import Qt 4.6\nTextInput { text: \"" + standard.at(i) + "\" }";
- QmlComponent textinputComponent(&engine);
- textinputComponent.setData(componentStr.toLatin1(), QUrl());
- QmlGraphicsTextInput *textinputObject = qobject_cast<QmlGraphicsTextInput*>(textinputComponent.create());
-
- QVERIFY(textinputObject != 0);
- QCOMPARE(textinputObject->width(), qreal(metricWidth) + 1.);//1 for the cursor
- }
-}
-
-void tst_qmlgraphicstextinput::font()
-{
- //test size, then bold, then italic, then family
- {
- QString componentStr = "import Qt 4.6\nTextInput { font.pointSize: 40; text: \"Hello World\" }";
- QmlComponent textinputComponent(&engine);
- textinputComponent.setData(componentStr.toLatin1(), QUrl());
- QmlGraphicsTextInput *textinputObject = qobject_cast<QmlGraphicsTextInput*>(textinputComponent.create());
-
- QVERIFY(textinputObject != 0);
- QCOMPARE(textinputObject->font().pointSize(), 40);
- QCOMPARE(textinputObject->font().bold(), false);
- QCOMPARE(textinputObject->font().italic(), false);
- }
-
- {
- QString componentStr = "import Qt 4.6\nTextInput { font.bold: true; text: \"Hello World\" }";
- QmlComponent textinputComponent(&engine);
- textinputComponent.setData(componentStr.toLatin1(), QUrl());
- QmlGraphicsTextInput *textinputObject = qobject_cast<QmlGraphicsTextInput*>(textinputComponent.create());
-
- QVERIFY(textinputObject != 0);
- QCOMPARE(textinputObject->font().bold(), true);
- QCOMPARE(textinputObject->font().italic(), false);
- }
-
- {
- QString componentStr = "import Qt 4.6\nTextInput { font.italic: true; text: \"Hello World\" }";
- QmlComponent textinputComponent(&engine);
- textinputComponent.setData(componentStr.toLatin1(), QUrl());
- QmlGraphicsTextInput *textinputObject = qobject_cast<QmlGraphicsTextInput*>(textinputComponent.create());
-
- QVERIFY(textinputObject != 0);
- QCOMPARE(textinputObject->font().italic(), true);
- QCOMPARE(textinputObject->font().bold(), false);
- }
-
- {
- QString componentStr = "import Qt 4.6\nTextInput { font.family: \"Helvetica\"; text: \"Hello World\" }";
- QmlComponent textinputComponent(&engine);
- textinputComponent.setData(componentStr.toLatin1(), QUrl());
- QmlGraphicsTextInput *textinputObject = qobject_cast<QmlGraphicsTextInput*>(textinputComponent.create());
-
- QVERIFY(textinputObject != 0);
- QCOMPARE(textinputObject->font().family(), QString("Helvetica"));
- QCOMPARE(textinputObject->font().bold(), false);
- QCOMPARE(textinputObject->font().italic(), false);
- }
-
- {
- QString componentStr = "import Qt 4.6\nTextInput { font.family: \"\"; text: \"Hello World\" }";
- QmlComponent textinputComponent(&engine);
- textinputComponent.setData(componentStr.toLatin1(), QUrl());
- QmlGraphicsTextInput *textinputObject = qobject_cast<QmlGraphicsTextInput*>(textinputComponent.create());
-
- QVERIFY(textinputObject != 0);
- QCOMPARE(textinputObject->font().family(), QString(""));
- }
-}
-
-void tst_qmlgraphicstextinput::color()
-{
- //test color
- for (int i = 0; i < colorStrings.size(); i++)
- {
- QString componentStr = "import Qt 4.6\nTextInput { color: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
- QmlComponent textinputComponent(&engine);
- textinputComponent.setData(componentStr.toLatin1(), QUrl());
- QmlGraphicsTextInput *textinputObject = qobject_cast<QmlGraphicsTextInput*>(textinputComponent.create());
- QVERIFY(textinputObject != 0);
- QCOMPARE(textinputObject->color(), QColor(colorStrings.at(i)));
- }
-
- //test selection color
- for (int i = 0; i < colorStrings.size(); i++)
- {
- QString componentStr = "import Qt 4.6\nTextInput { selectionColor: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
- QmlComponent textinputComponent(&engine);
- textinputComponent.setData(componentStr.toLatin1(), QUrl());
- QmlGraphicsTextInput *textinputObject = qobject_cast<QmlGraphicsTextInput*>(textinputComponent.create());
- QVERIFY(textinputObject != 0);
- QCOMPARE(textinputObject->selectionColor(), QColor(colorStrings.at(i)));
- }
-
- //test selected text color
- for (int i = 0; i < colorStrings.size(); i++)
- {
- QString componentStr = "import Qt 4.6\nTextInput { selectedTextColor: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
- QmlComponent textinputComponent(&engine);
- textinputComponent.setData(componentStr.toLatin1(), QUrl());
- QmlGraphicsTextInput *textinputObject = qobject_cast<QmlGraphicsTextInput*>(textinputComponent.create());
- QVERIFY(textinputObject != 0);
- QCOMPARE(textinputObject->selectedTextColor(), QColor(colorStrings.at(i)));
- }
-
- {
- QString colorStr = "#AA001234";
- QColor testColor("#001234");
- testColor.setAlpha(170);
-
- QString componentStr = "import Qt 4.6\nTextInput { color: \"" + colorStr + "\"; text: \"Hello World\" }";
- QmlComponent textinputComponent(&engine);
- textinputComponent.setData(componentStr.toLatin1(), QUrl());
- QmlGraphicsTextInput *textinputObject = qobject_cast<QmlGraphicsTextInput*>(textinputComponent.create());
-
- QVERIFY(textinputObject != 0);
- QCOMPARE(textinputObject->color(), testColor);
- }
-}
-
-void tst_qmlgraphicstextinput::selection()
-{
- QString testStr = standard[0];
- QString componentStr = "import Qt 4.6\nTextInput { text: \""+ testStr +"\"; }";
- QmlComponent textinputComponent(&engine);
- textinputComponent.setData(componentStr.toLatin1(), QUrl());
- QmlGraphicsTextInput *textinputObject = qobject_cast<QmlGraphicsTextInput*>(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());
-
- //Test selection
- for(int i=0; i<= testStr.size(); i++) {
- textinputObject->setSelectionEnd(i);
- QCOMPARE(testStr.mid(0,i), textinputObject->selectedText());
- }
- for(int i=0; i<= testStr.size(); i++) {
- textinputObject->setSelectionStart(i);
- 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());
-
- for(int i=0; i< testStr.size(); i++) {
- textinputObject->setSelectionStart(i);
- QCOMPARE(textinputObject->selectionEnd(), i);
- QCOMPARE(testStr.mid(i,0), textinputObject->selectedText());
- textinputObject->setSelectionEnd(i+1);
- QCOMPARE(textinputObject->selectionStart(), i);
- QCOMPARE(testStr.mid(i,1), textinputObject->selectedText());
- }
-
- for(int i= testStr.size() - 1; i>0; i--) {
- textinputObject->setSelectionEnd(i);
- QCOMPARE(testStr.mid(i,0), textinputObject->selectedText());
- textinputObject->setSelectionStart(i-1);
- QCOMPARE(testStr.mid(i-1,1), textinputObject->selectedText());
- }
-
- //Test Error Ignoring behaviour
- textinputObject->setCursorPosition(0);
- QVERIFY(textinputObject->selectedText().isNull());
- textinputObject->setSelectionStart(-10);
- QVERIFY(textinputObject->selectedText().isNull());
- textinputObject->setSelectionStart(100);
- QVERIFY(textinputObject->selectedText().isNull());
- textinputObject->setSelectionEnd(-10);
- QVERIFY(textinputObject->selectedText().isNull());
- textinputObject->setSelectionEnd(100);
- QVERIFY(textinputObject->selectedText().isNull());
- textinputObject->setSelectionStart(0);
- textinputObject->setSelectionEnd(10);
- QVERIFY(textinputObject->selectedText().size() == 10);
- textinputObject->setSelectionStart(-10);
- QVERIFY(textinputObject->selectedText().size() == 10);
- textinputObject->setSelectionStart(100);
- QVERIFY(textinputObject->selectedText().size() == 10);
- textinputObject->setSelectionEnd(-10);
- QVERIFY(textinputObject->selectedText().size() == 10);
- textinputObject->setSelectionEnd(100);
- QVERIFY(textinputObject->selectedText().size() == 10);
-}
-
-void tst_qmlgraphicstextinput::maxLength()
-{
- //QString componentStr = "import Qt 4.6\nTextInput { maximumLength: 10; }";
- QmlView *canvas = createView(SRCDIR "/data/maxLength.qml");
- canvas->execute();
- canvas->show();
- canvas->setFocus();
- QVERIFY(canvas->rootObject() != 0);
- QmlGraphicsTextInput *textinputObject = qobject_cast<QmlGraphicsTextInput *>(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->hasFocus() == true);
- for(int i=0; i<20; i++){
- QCOMPARE(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);
- }
-}
-
-void tst_qmlgraphicstextinput::masks()
-{
- //Not a comprehensive test of the possible masks, that's done elsewhere (QLineEdit)
- //QString componentStr = "import Qt 4.6\nTextInput { inputMask: 'HHHHhhhh'; }";
- QmlView *canvas = createView(SRCDIR "/data/masks.qml");
- canvas->execute();
- canvas->show();
- canvas->setFocus();
- QVERIFY(canvas->rootObject() != 0);
- QmlGraphicsTextInput *textinputObject = qobject_cast<QmlGraphicsTextInput *>(canvas->rootObject());
- QVERIFY(textinputObject != 0);
- QTRY_VERIFY(textinputObject->hasFocus() == true);
- QVERIFY(textinputObject->text().length() == 0);
- QCOMPARE(textinputObject->inputMask(), QString("HHHHhhhh; "));
- for(int i=0; i<10; i++){
- QCOMPARE(qMin(i,8), textinputObject->text().length());
- 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);
- }
-}
-
-void tst_qmlgraphicstextinput::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.
-
- QmlView *canvas = createView(SRCDIR "/data/validators.qml");
- canvas->execute();
- canvas->show();
- canvas->setFocus();
-
- QVERIFY(canvas->rootObject() != 0);
-
- QmlGraphicsTextInput *intInput = qobject_cast<QmlGraphicsTextInput *>(qvariant_cast<QObject *>(canvas->rootObject()->property("intInput")));
- QVERIFY(intInput);
- intInput->setFocus(true);
- QTRY_VERIFY(intInput->hasFocus());
- QTest::keyPress(canvas, Qt::Key_1);
- QTest::keyRelease(canvas, Qt::Key_1, Qt::NoModifier ,10);
- QCOMPARE(intInput->text(), QLatin1String("1"));
- QCOMPARE(intInput->hasAcceptableInput(), false);
- QTest::keyPress(canvas, Qt::Key_2);
- QTest::keyRelease(canvas, Qt::Key_2, Qt::NoModifier ,10);
- QCOMPARE(intInput->text(), QLatin1String("1"));
- QCOMPARE(intInput->hasAcceptableInput(), false);
- QTest::keyPress(canvas, Qt::Key_1);
- QTest::keyRelease(canvas, Qt::Key_1, Qt::NoModifier ,10);
- QCOMPARE(intInput->text(), QLatin1String("11"));
- QCOMPARE(intInput->hasAcceptableInput(), true);
- QTest::keyPress(canvas, Qt::Key_0);
- QTest::keyRelease(canvas, Qt::Key_0, Qt::NoModifier ,10);
- QCOMPARE(intInput->text(), QLatin1String("11"));
- QCOMPARE(intInput->hasAcceptableInput(), true);
-
- QmlGraphicsTextInput *dblInput = qobject_cast<QmlGraphicsTextInput *>(qvariant_cast<QObject *>(canvas->rootObject()->property("dblInput")));
- QTRY_VERIFY(dblInput);
- dblInput->setFocus(true);
- QVERIFY(dblInput->hasFocus() == true);
- QTest::keyPress(canvas, Qt::Key_1);
- QTest::keyRelease(canvas, Qt::Key_1, Qt::NoModifier ,10);
- QCOMPARE(dblInput->text(), QLatin1String("1"));
- QCOMPARE(dblInput->hasAcceptableInput(), false);
- QTest::keyPress(canvas, Qt::Key_2);
- QTest::keyRelease(canvas, Qt::Key_2, Qt::NoModifier ,10);
- QCOMPARE(dblInput->text(), QLatin1String("12"));
- QCOMPARE(dblInput->hasAcceptableInput(), true);
- QTest::keyPress(canvas, Qt::Key_Period);
- QTest::keyRelease(canvas, Qt::Key_Period, Qt::NoModifier ,10);
- QCOMPARE(dblInput->text(), QLatin1String("12."));
- QCOMPARE(dblInput->hasAcceptableInput(), true);
- QTest::keyPress(canvas, Qt::Key_1);
- QTest::keyRelease(canvas, Qt::Key_1, Qt::NoModifier ,10);
- QCOMPARE(dblInput->text(), QLatin1String("12.1"));
- QCOMPARE(dblInput->hasAcceptableInput(), true);
- QTest::keyPress(canvas, Qt::Key_1);
- QTest::keyRelease(canvas, Qt::Key_1, Qt::NoModifier ,10);
- QCOMPARE(dblInput->text(), QLatin1String("12.11"));
- QCOMPARE(dblInput->hasAcceptableInput(), true);
- QTest::keyPress(canvas, Qt::Key_1);
- QTest::keyRelease(canvas, Qt::Key_1, Qt::NoModifier ,10);
- QCOMPARE(dblInput->text(), QLatin1String("12.11"));
- QCOMPARE(dblInput->hasAcceptableInput(), true);
-
- QmlGraphicsTextInput *strInput = qobject_cast<QmlGraphicsTextInput *>(qvariant_cast<QObject *>(canvas->rootObject()->property("strInput")));
- QTRY_VERIFY(strInput);
- strInput->setFocus(true);
- QVERIFY(strInput->hasFocus() == true);
- QTest::keyPress(canvas, Qt::Key_1);
- QTest::keyRelease(canvas, Qt::Key_1, Qt::NoModifier ,10);
- QEXPECT_FAIL("","Will not work until QTBUG-8025 is resolved", Abort);
- QCOMPARE(strInput->text(), QLatin1String(""));
- QCOMPARE(strInput->hasAcceptableInput(), false);
- QTest::keyPress(canvas, Qt::Key_A);
- QTest::keyRelease(canvas, Qt::Key_A, Qt::NoModifier ,10);
- QCOMPARE(strInput->text(), QLatin1String("a"));
- QCOMPARE(strInput->hasAcceptableInput(), false);
- QTest::keyPress(canvas, Qt::Key_A);
- QTest::keyRelease(canvas, Qt::Key_A, Qt::NoModifier ,10);
- QCOMPARE(strInput->text(), QLatin1String("aa"));
- QCOMPARE(strInput->hasAcceptableInput(), true);
- QTest::keyPress(canvas, Qt::Key_A);
- QTest::keyRelease(canvas, Qt::Key_A, Qt::NoModifier ,10);
- QCOMPARE(strInput->text(), QLatin1String("aaa"));
- QCOMPARE(strInput->hasAcceptableInput(), true);
- QTest::keyPress(canvas, Qt::Key_A);
- QTest::keyRelease(canvas, Qt::Key_A, Qt::NoModifier ,10);
- QCOMPARE(strInput->text(), QLatin1String("aaaa"));
- QCOMPARE(strInput->hasAcceptableInput(), true);
- QTest::keyPress(canvas, Qt::Key_A);
- QTest::keyRelease(canvas, Qt::Key_A, Qt::NoModifier ,10);
- QCOMPARE(strInput->text(), QLatin1String("aaaa"));
- QCOMPARE(strInput->hasAcceptableInput(), true);
-}
-
-void tst_qmlgraphicstextinput::inputMethodHints()
-{
- QmlView *canvas = createView(SRCDIR "/data/inputmethodhints.qml");
- canvas->execute();
- canvas->show();
- canvas->setFocus();
-
- QVERIFY(canvas->rootObject() != 0);
- QmlGraphicsTextInput *textinputObject = qobject_cast<QmlGraphicsTextInput *>(canvas->rootObject());
- QVERIFY(textinputObject != 0);
- QVERIFY(textinputObject->inputMethodHints() & Qt::ImhNoPredictiveText);
- textinputObject->setInputMethodHints(Qt::ImhUppercaseOnly);
- QVERIFY(textinputObject->inputMethodHints() & Qt::ImhUppercaseOnly);
-}
-
-/*
-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_qmlgraphicstextinput::navigation()
-{
- QmlView *canvas = createView(SRCDIR "/data/navigation.qml");
- canvas->execute();
- canvas->show();
- canvas->setFocus();
-
- QVERIFY(canvas->rootObject() != 0);
-
- QmlGraphicsTextInput *input = qobject_cast<QmlGraphicsTextInput *>(qvariant_cast<QObject *>(canvas->rootObject()->property("myInput")));
-
- QVERIFY(input != 0);
- input->setCursorPosition(0);
- QTRY_VERIFY(input->hasFocus() == true);
- simulateKey(canvas, Qt::Key_Left);
- QVERIFY(input->hasFocus() == false);
- simulateKey(canvas, Qt::Key_Right);
- QVERIFY(input->hasFocus() == true);
- //QT-2944: If text is selected, then we should deselect first.
- input->setCursorPosition(input->text().length());
- input->setSelectionStart(0);
- input->setSelectionEnd(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->hasFocus() == true);
- simulateKey(canvas, Qt::Key_Right);
- QVERIFY(input->hasFocus() == false);
- simulateKey(canvas, Qt::Key_Left);
- QVERIFY(input->hasFocus() == true);
-}
-
-void tst_qmlgraphicstextinput::cursorDelegate()
-{
- QmlView* view = createView(SRCDIR "/data/cursorTest.qml");
- view->execute();
- view->show();
- view->setFocus();
- QmlGraphicsTextInput *textInputObject = view->rootObject()->findChild<QmlGraphicsTextInput*>("textInputObject");
- QVERIFY(textInputObject != 0);
- QVERIFY(textInputObject->findChild<QmlGraphicsItem*>("cursorInstance"));
- //Test Delegate gets created
- textInputObject->setFocus(true);
- QmlGraphicsItem* delegateObject = textInputObject->findChild<QmlGraphicsItem*>("cursorInstance");
- QVERIFY(delegateObject);
- //Test Delegate gets moved
- for(int i=0; i<= textInputObject->text().length(); i++){
- textInputObject->setCursorPosition(i);
- //+5 is because the TextInput cursorRect is just a 10xHeight area centered on cursor position
- QCOMPARE(textInputObject->cursorRect().x() + 5, qRound(delegateObject->x()));
- QCOMPARE(textInputObject->cursorRect().y(), qRound(delegateObject->y()));
- }
- textInputObject->setCursorPosition(0);
- QCOMPARE(textInputObject->cursorRect().x()+5, qRound(delegateObject->x()));
- QCOMPARE(textInputObject->cursorRect().y(), qRound(delegateObject->y()));
- //Test Delegate gets deleted
- textInputObject->setCursorDelegate(0);
- QVERIFY(!textInputObject->findChild<QmlGraphicsItem*>("cursorInstance"));
-}
-
-void tst_qmlgraphicstextinput::readOnly()
-{
- QmlView *canvas = createView(SRCDIR "/data/readOnly.qml");
- canvas->execute();
- canvas->show();
- canvas->setFocus();
-
- QVERIFY(canvas->rootObject() != 0);
-
- QmlGraphicsTextInput *input = qobject_cast<QmlGraphicsTextInput *>(qvariant_cast<QObject *>(canvas->rootObject()->property("myInput")));
-
- QVERIFY(input != 0);
- QTRY_VERIFY(input->hasFocus() == 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);
-}
-
-void tst_qmlgraphicstextinput::simulateKey(QmlView *view, int key)
-{
- QKeyEvent press(QKeyEvent::KeyPress, key, 0);
- QKeyEvent release(QKeyEvent::KeyRelease, key, 0);
-
- QApplication::sendEvent(view, &press);
- QApplication::sendEvent(view, &release);
-}
-
-QmlView *tst_qmlgraphicstextinput::createView(const QString &filename)
-{
- QmlView *canvas = new QmlView(0);
-
- canvas->setSource(QUrl::fromLocalFile(filename));
-
- return canvas;
-}
-
-class MyInputContext : public QInputContext
-{
-public:
- MyInputContext() : softwareInputPanelEventReceived(false) {}
- ~MyInputContext() {}
-
- QString identifierName() { return QString(); }
- QString language() { return QString(); }
-
- void reset() {}
-
- bool isComposing() const { return false; }
-
- bool filterEvent( const QEvent *event )
- {
- if (event->type() == QEvent::RequestSoftwareInputPanel)
- softwareInputPanelEventReceived = true;
- return QInputContext::filterEvent(event);
- }
- bool softwareInputPanelEventReceived;
-};
-
-void tst_qmlgraphicstextinput::sendRequestSoftwareInputPanelEvent()
-{
- QGraphicsScene scene;
- QGraphicsView view(&scene);
- MyInputContext ic;
- view.viewport()->setInputContext(&ic);
- QStyle::RequestSoftwareInputPanel behavior = QStyle::RequestSoftwareInputPanel(
- view.style()->styleHint(QStyle::SH_RequestSoftwareInputPanel));
- if ((behavior != QStyle::RSIP_OnMouseClick))
- QSKIP("This test need to have a style with RSIP_OnMouseClick", SkipSingle);
- QmlGraphicsTextInput input;
- input.setText("Hello world");
- input.setPos(0, 0);
- scene.addItem(&input);
- view.show();
- qApp->setAutoSipEnabled(true);
- QApplication::setActiveWindow(&view);
- QTest::qWaitForWindowShown(&view);
- QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&view));
- QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(input.scenePos()));
- QApplication::processEvents();
- QCOMPARE(ic.softwareInputPanelEventReceived, true);
-}
-
-QTEST_MAIN(tst_qmlgraphicstextinput)
-
-#include "tst_qmlgraphicstextinput.moc"
diff --git a/tests/auto/declarative/qmlgraphicswebview/data/forward.html b/tests/auto/declarative/qmlgraphicswebview/data/forward.html
deleted file mode 100644
index 030446a..0000000
--- a/tests/auto/declarative/qmlgraphicswebview/data/forward.html
+++ /dev/null
@@ -1,12 +0,0 @@
-<html>
-<head><title>Forward</title>
-<link rel="icon" sizes="48x48" href="basic.png">
-</head>
-<body leftmargin="0" marginwidth="0">
-<table width="123">
-<tbody>
-<tr><td>This is more.</td></tr>
-</tbody>
-</table>
-</body>
-</html>
diff --git a/tests/auto/declarative/qmlgraphicswebview/qmlgraphicswebview.pro b/tests/auto/declarative/qmlgraphicswebview/qmlgraphicswebview.pro
deleted file mode 100644
index a590616..0000000
--- a/tests/auto/declarative/qmlgraphicswebview/qmlgraphicswebview.pro
+++ /dev/null
@@ -1,10 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative
-contains(QT_CONFIG,webkit): QT += webkit
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qmlgraphicswebview.cpp testtypes.cpp
-HEADERS += testtypes.h
-
-# Define SRCDIR equal to test's source directory
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmlgraphicswebview/testtypes.cpp b/tests/auto/declarative/qmlgraphicswebview/testtypes.cpp
deleted file mode 100644
index 00c1b67..0000000
--- a/tests/auto/declarative/qmlgraphicswebview/testtypes.cpp
+++ /dev/null
@@ -1,49 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include "testtypes.h"
-
-void MyWebView::drawContents(QPainter *p, const QRect &r)
-{
- pp += r.width()*r.height();
- QmlGraphicsWebView::drawContents(p,r);
-}
-
-QML_DEFINE_TYPE(Test,1,0,MyWebView,MyWebView);
diff --git a/tests/auto/declarative/qmlgraphicswebview/testtypes.h b/tests/auto/declarative/qmlgraphicswebview/testtypes.h
deleted file mode 100644
index 0b3176d..0000000
--- a/tests/auto/declarative/qmlgraphicswebview/testtypes.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef TESTTYPES_H
-#define TESTTYPES_H
-
-#include <private/qmlgraphicswebview_p.h>
-
-class MyWebView : public QmlGraphicsWebView
-{
- Q_OBJECT
- Q_PROPERTY(int pixelsPainted READ pixelsPainted);
-
-public:
- MyWebView() : pp(0) {}
-
- int pixelsPainted() const { return pp; }
-
- void drawContents(QPainter *p, const QRect &r);
-
-private:
- int pp;
-};
-
-QML_DECLARE_TYPE(MyWebView);
-
-#endif // TESTTYPES_H
diff --git a/tests/auto/declarative/qmlgraphicswebview/tst_qmlgraphicswebview.cpp b/tests/auto/declarative/qmlgraphicswebview/tst_qmlgraphicswebview.cpp
deleted file mode 100644
index f3c39f8..0000000
--- a/tests/auto/declarative/qmlgraphicswebview/tst_qmlgraphicswebview.cpp
+++ /dev/null
@@ -1,396 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include "../../../shared/util.h"
-#include <QtDeclarative/qmlengine.h>
-#include <QtDeclarative/qmlcomponent.h>
-#include <private/qmlgraphicswebview_p.h>
-#include <private/qmlgraphicswebview_p_p.h>
-#include <private/qmlgraphicspositioners_p.h>
-#include <QtWebKit/qwebpage.h>
-#include <QtWebKit/qwebframe.h>
-#include <QtCore/qdir.h>
-#include <QtCore/qfile.h>
-#include <QtGui/qpainter.h>
-#include "testtypes.h"
-
-class tst_qmlgraphicswebview : public QObject
-{
- Q_OBJECT
-public:
- tst_qmlgraphicswebview() {}
-
-private slots:
- void basicProperties();
- void settings();
- void historyNav();
- void multipleWindows();
- void elementAreaAt();
- void loadError();
- void setHtml();
- void javaScript();
- void cleanupTestCase();
- void pixelCache();
-
-private:
- void checkNoErrors(const QmlComponent& component);
- QmlEngine engine;
- QString tmpDir() const
- {
- static QString tmpd = QDir::tempPath()+"/tst_qmlgraphicswebview-"
- + QDateTime::currentDateTime().toString(QLatin1String("yyyyMMddhhmmss"));
- return tmpd;
- }
-};
-
-static QString strippedHtml(QString html)
-{
- html.replace(QRegExp("\\s+"),"");
- return html;
-}
-
-static QString fileContents(const QString& filename)
-{
- QFile file(filename);
- file.open(QIODevice::ReadOnly);
- return QString::fromUtf8(file.readAll());
-}
-
-
-static void removeRecursive(const QString& dirname)
-{
- QDir dir(dirname);
- QFileInfoList entries(dir.entryInfoList(QDir::Dirs|QDir::Files|QDir::NoDotAndDotDot));
- for (int i = 0; i < entries.count(); ++i)
- if (entries[i].isDir())
- removeRecursive(entries[i].filePath());
- else
- dir.remove(entries[i].fileName());
- QDir().rmdir(dirname);
-}
-
-void tst_qmlgraphicswebview::cleanupTestCase()
-{
- removeRecursive(tmpDir());
-}
-
-void tst_qmlgraphicswebview::checkNoErrors(const QmlComponent& component)
-{
- // Wait until the component is ready
- QTRY_VERIFY(component.isReady());
-
-
- if (component.isError()) {
- QList<QmlError> errors = component.errors();
- for (int ii = 0; ii < errors.count(); ++ii) {
- const QmlError &error = errors.at(ii);
- QByteArray errorStr = QByteArray::number(error.line()) + ":" +
- QByteArray::number(error.column()) + ":" +
- error.description().toUtf8();
- qWarning() << errorStr;
- }
- }
- QVERIFY(!component.isError());
-}
-
-void tst_qmlgraphicswebview::basicProperties()
-{
- QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/basic.qml"));
- checkNoErrors(component);
- QWebSettings::enablePersistentStorage(tmpDir());
-
- QmlGraphicsWebView *wv = qobject_cast<QmlGraphicsWebView*>(component.create());
- QVERIFY(wv != 0);
- QTRY_COMPARE(wv->progress(), 1.0);
- QCOMPARE(wv->title(),QString("Basic"));
- QTRY_COMPARE(wv->icon().width(), 48);
- QCOMPARE(wv->icon(),QPixmap(SRCDIR "/data/basic.png"));
- QCOMPARE(wv->statusText(),QString("status here"));
- QCOMPARE(strippedHtml(fileContents(SRCDIR "/data/basic.html")), strippedHtml(wv->html()));
- QCOMPARE(wv->width(), 123.0);
- QCOMPARE(wv->preferredWidth(), 0);
- QCOMPARE(wv->preferredHeight(), 0);
- QCOMPARE(wv->zoomFactor(), 1.0);
- QCOMPARE(wv->url(), QUrl::fromLocalFile(SRCDIR "/data/basic.html"));
- QCOMPARE(wv->status(), QmlGraphicsWebView::Ready);
- QVERIFY(wv->reloadAction());
- QVERIFY(wv->reloadAction()->isEnabled());
- QVERIFY(wv->backAction());
- QVERIFY(!wv->backAction()->isEnabled());
- QVERIFY(wv->forwardAction());
- QVERIFY(!wv->forwardAction()->isEnabled());
- QVERIFY(wv->stopAction());
- QVERIFY(!wv->stopAction()->isEnabled());
-
- wv->setPixelCacheSize(0); // mainly testing that it doesn't crash or anything!
- QCOMPARE(wv->pixelCacheSize(),0);
- wv->reloadAction()->trigger();
- QTRY_COMPARE(wv->progress(), 1.0);
-}
-
-void tst_qmlgraphicswebview::settings()
-{
- QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/basic.qml"));
- checkNoErrors(component);
- QmlGraphicsWebView *wv = qobject_cast<QmlGraphicsWebView*>(component.create());
- QVERIFY(wv != 0);
- QTRY_COMPARE(wv->progress(), 1.0);
-
- QmlGraphicsWebSettings *s = wv->settingsObject();
-
- // merely tests that setting gets stored (in QWebSettings)
- // behavioural tests are in WebKit.
- for (int b=0; b<=1; ++b) {
- bool on = !!b;
-
- s->setAutoLoadImages(on);
- s->setDeveloperExtrasEnabled(on);
- s->setJavaEnabled(on);
- s->setJavascriptCanAccessClipboard(on);
- s->setJavascriptCanOpenWindows(on);
- s->setJavascriptEnabled(on);
- s->setLinksIncludedInFocusChain(on);
- s->setLocalContentCanAccessRemoteUrls(on);
- s->setLocalStorageDatabaseEnabled(on);
- s->setOfflineStorageDatabaseEnabled(on);
- s->setOfflineWebApplicationCacheEnabled(on);
- s->setPluginsEnabled(on);
- s->setPrintElementBackgrounds(on);
- s->setPrivateBrowsingEnabled(on);
- s->setZoomTextOnly(on);
-
- QVERIFY(s->autoLoadImages() == on);
- QVERIFY(s->developerExtrasEnabled() == on);
- QVERIFY(s->javaEnabled() == on);
- QVERIFY(s->javascriptCanAccessClipboard() == on);
- QVERIFY(s->javascriptCanOpenWindows() == on);
- QVERIFY(s->javascriptEnabled() == on);
- QVERIFY(s->linksIncludedInFocusChain() == on);
- QVERIFY(s->localContentCanAccessRemoteUrls() == on);
- QVERIFY(s->localStorageDatabaseEnabled() == on);
- QVERIFY(s->offlineStorageDatabaseEnabled() == on);
- QVERIFY(s->offlineWebApplicationCacheEnabled() == on);
- QVERIFY(s->pluginsEnabled() == on);
- QVERIFY(s->printElementBackgrounds() == on);
- QVERIFY(s->privateBrowsingEnabled() == on);
- QVERIFY(s->zoomTextOnly() == on);
-
- QVERIFY(s->property("autoLoadImages") == on);
- QVERIFY(s->property("developerExtrasEnabled") == on);
- QVERIFY(s->property("javaEnabled") == on);
- QVERIFY(s->property("javascriptCanAccessClipboard") == on);
- QVERIFY(s->property("javascriptCanOpenWindows") == on);
- QVERIFY(s->property("javascriptEnabled") == on);
- QVERIFY(s->property("linksIncludedInFocusChain") == on);
- QVERIFY(s->property("localContentCanAccessRemoteUrls") == on);
- QVERIFY(s->property("localStorageDatabaseEnabled") == on);
- QVERIFY(s->property("offlineStorageDatabaseEnabled") == on);
- QVERIFY(s->property("offlineWebApplicationCacheEnabled") == on);
- QVERIFY(s->property("pluginsEnabled") == on);
- QVERIFY(s->property("printElementBackgrounds") == on);
- QVERIFY(s->property("privateBrowsingEnabled") == on);
- QVERIFY(s->property("zoomTextOnly") == on);
- }
-}
-
-void tst_qmlgraphicswebview::historyNav()
-{
- QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/basic.qml"));
- checkNoErrors(component);
- QWebSettings::enablePersistentStorage(tmpDir());
-
- QmlGraphicsWebView *wv = qobject_cast<QmlGraphicsWebView*>(component.create());
- QVERIFY(wv != 0);
- for (int i=1; i<=2; ++i) {
- QTRY_COMPARE(wv->progress(), 1.0);
- QCOMPARE(wv->title(),QString("Basic"));
- QTRY_COMPARE(wv->icon().width(), 48);
- QCOMPARE(wv->icon(),QPixmap(SRCDIR "/data/basic.png"));
- QCOMPARE(wv->statusText(),QString("status here"));
- QCOMPARE(strippedHtml(fileContents(SRCDIR "/data/basic.html")), strippedHtml(wv->html()));
- QCOMPARE(wv->width(), 123.0);
- QCOMPARE(wv->preferredWidth(), 0);
- QCOMPARE(wv->zoomFactor(), 1.0);
- QCOMPARE(wv->url(), QUrl::fromLocalFile(SRCDIR "/data/basic.html"));
- QCOMPARE(wv->status(), QmlGraphicsWebView::Ready);
- QVERIFY(wv->reloadAction());
- QVERIFY(wv->reloadAction()->isEnabled());
- QVERIFY(wv->backAction());
- QVERIFY(!wv->backAction()->isEnabled());
- QVERIFY(wv->forwardAction());
- QVERIFY(!wv->forwardAction()->isEnabled());
- QVERIFY(wv->stopAction());
- QVERIFY(!wv->stopAction()->isEnabled());
-
- wv->reloadAction()->trigger();
- }
-
- wv->setUrl(QUrl::fromLocalFile(SRCDIR "/data/forward.html"));
- QTRY_COMPARE(wv->progress(), 1.0);
- QCOMPARE(wv->title(),QString("Forward"));
- QCOMPARE(strippedHtml(fileContents(SRCDIR "/data/forward.html")), strippedHtml(wv->html()));
- QCOMPARE(wv->url(), QUrl::fromLocalFile(SRCDIR "/data/forward.html"));
- QCOMPARE(wv->status(), QmlGraphicsWebView::Ready);
- QCOMPARE(wv->statusText(),QString(""));
- QVERIFY(wv->reloadAction());
- QVERIFY(wv->reloadAction()->isEnabled());
- QVERIFY(wv->backAction());
- QVERIFY(wv->backAction()->isEnabled());
- QVERIFY(wv->forwardAction());
- QVERIFY(!wv->forwardAction()->isEnabled());
- QVERIFY(wv->stopAction());
- QVERIFY(!wv->stopAction()->isEnabled());
-
- wv->backAction()->trigger();
-
- QTRY_COMPARE(wv->progress(), 1.0);
- QCOMPARE(wv->title(),QString("Basic"));
- QCOMPARE(strippedHtml(fileContents(SRCDIR "/data/basic.html")), strippedHtml(wv->html()));
- QCOMPARE(wv->url(), QUrl::fromLocalFile(SRCDIR "/data/basic.html"));
- QCOMPARE(wv->status(), QmlGraphicsWebView::Ready);
- QVERIFY(wv->reloadAction());
- QVERIFY(wv->reloadAction()->isEnabled());
- QVERIFY(wv->backAction());
- QVERIFY(!wv->backAction()->isEnabled());
- QVERIFY(wv->forwardAction());
- QVERIFY(wv->forwardAction()->isEnabled());
- QVERIFY(wv->stopAction());
- QVERIFY(!wv->stopAction()->isEnabled());
-}
-
-void tst_qmlgraphicswebview::multipleWindows()
-{
- QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/newwindows.qml"));
- checkNoErrors(component);
-
- QmlGraphicsGrid *grid = qobject_cast<QmlGraphicsGrid*>(component.create());
- QVERIFY(grid != 0);
- QTRY_COMPARE(grid->children().count(), 2+5); // Component, Loader, 5 WebViews
- QmlGraphicsItem* popup = qobject_cast<QmlGraphicsItem*>(grid->children().at(3)); // first popup after Component, Loaded, original.
- QVERIFY(popup != 0);
- QTRY_COMPARE(popup->x(), 150.0);
-}
-
-void tst_qmlgraphicswebview::loadError()
-{
- QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/loadError.qml"));
- checkNoErrors(component);
- QWebSettings::enablePersistentStorage(tmpDir());
-
- QmlGraphicsWebView *wv = qobject_cast<QmlGraphicsWebView*>(component.create());
- QVERIFY(wv != 0);
- for (int i=1; i<=2; ++i) {
- QTRY_COMPARE(wv->progress(), 1.0);
- QCOMPARE(wv->title(),QString(""));
- QCOMPARE(wv->statusText(),QString("")); // HTML 'status bar' text, not error message
- QCOMPARE(wv->url(), QUrl::fromLocalFile(SRCDIR "/data/does-not-exist.html")); // Unlike QWebPage, which loses url
- QCOMPARE(wv->status(), QmlGraphicsWebView::Error);
-
- wv->reloadAction()->trigger();
- }
-}
-
-void tst_qmlgraphicswebview::setHtml()
-{
- QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/sethtml.qml"));
- checkNoErrors(component);
- QmlGraphicsWebView *wv = qobject_cast<QmlGraphicsWebView*>(component.create());
- QVERIFY(wv != 0);
- QCOMPARE(wv->html(),QString("<html><head></head><body><p>This is a <b>string</b> set on the WebView</p></body></html>"));
-}
-
-void tst_qmlgraphicswebview::elementAreaAt()
-{
- QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/elements.qml"));
- checkNoErrors(component);
- QmlGraphicsWebView *wv = qobject_cast<QmlGraphicsWebView*>(component.create());
- QVERIFY(wv != 0);
- QTRY_COMPARE(wv->progress(), 1.0);
-
- QCOMPARE(wv->elementAreaAt(40,30,100,100),QRect(1,1,75,54)); // Area A in data/elements.html
- QCOMPARE(wv->elementAreaAt(130,30,200,100),QRect(78,3,110,50)); // Area B
- QCOMPARE(wv->elementAreaAt(40,30,400,400),QRect(0,0,310,100)); // Whole view
- QCOMPARE(wv->elementAreaAt(130,30,280,280),QRect(76,1,223,54)); // Area BC
- QCOMPARE(wv->elementAreaAt(130,30,400,400),QRect(0,0,310,100)); // Whole view
-}
-
-void tst_qmlgraphicswebview::javaScript()
-{
- QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/javaScript.qml"));
- checkNoErrors(component);
- QmlGraphicsWebView *wv = qobject_cast<QmlGraphicsWebView*>(component.create());
- QVERIFY(wv != 0);
- QTRY_COMPARE(wv->progress(), 1.0);
- QCOMPARE(wv->evaluateJavaScript("123").toInt(), 123);
- QCOMPARE(wv->evaluateJavaScript("window.status").toString(), QString("status here"));
- QCOMPARE(wv->evaluateJavaScript("window.myjsname.qmlprop").toString(), QString("qmlvalue"));
-}
-
-void tst_qmlgraphicswebview::pixelCache()
-{
- QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/pixelCache.qml"));
- checkNoErrors(component);
- MyWebView *wv = qobject_cast<MyWebView*>(component.create());
- QVERIFY(wv != 0);
- QTRY_COMPARE(wv->progress(), 1.0);
- QPixmap pm(150,150);
- QPainter p(&pm);
- wv->paint(&p,0,0);
- const int expected = 120*(150+128); // 120 = width of HTML page, 150=pixmap height, 128=cache extra area
- QCOMPARE(wv->pixelsPainted(), expected);
- wv->paint(&p,0,0);
- QCOMPARE(wv->pixelsPainted(), expected); // nothing new needed to be painted
- wv->setPixelCacheSize(0); // clears the cache
- wv->paint(&p,0,0);
- QCOMPARE(wv->pixelsPainted(), expected*2); // everything needed to be painted
- // Note that painted things always go into the cache (even if they don't "fit"),
- // just that they will be removed if anything else needs to be painted.
- wv->setPixelCacheSize(expected); // won't clear the cache
- wv->paint(&p,0,0);
- QCOMPARE(wv->pixelsPainted(), expected*2); // still there
- wv->setPixelCacheSize(expected-1); // too small - will clear the cache
- wv->paint(&p,0,0);
- QCOMPARE(wv->pixelsPainted(), expected*3); // repainted
-}
-
-QTEST_MAIN(tst_qmlgraphicswebview)
-
-#include "tst_qmlgraphicswebview.moc"
diff --git a/tests/auto/declarative/qmlimageprovider/qmlimageprovider.pro b/tests/auto/declarative/qmlimageprovider/qmlimageprovider.pro
deleted file mode 100644
index 0ef7739..0000000
--- a/tests/auto/declarative/qmlimageprovider/qmlimageprovider.pro
+++ /dev/null
@@ -1,12 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative
-QT += network
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qmlimageprovider.cpp
-
-# QMAKE_CXXFLAGS = -fprofile-arcs -ftest-coverage
-# LIBS += -lgcov
-
-# Define SRCDIR equal to test's source directory
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmlimageprovider/tst_qmlimageprovider.cpp b/tests/auto/declarative/qmlimageprovider/tst_qmlimageprovider.cpp
deleted file mode 100644
index d07558a..0000000
--- a/tests/auto/declarative/qmlimageprovider/tst_qmlimageprovider.cpp
+++ /dev/null
@@ -1,166 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtTest/QtTest>
-#include <QtDeclarative/qmlengine.h>
-#include <QtDeclarative/qmlimageprovider.h>
-#include <private/qmlgraphicsimage_p.h>
-
-// QmlImageProvider::request() is run in an idle thread where possible
-// Be generous in our timeout.
-#define TRY_WAIT(expr) \
- do { \
- for (int ii = 0; ii < 10; ++ii) { \
- if ((expr)) break; \
- QTest::qWait(100); \
- } \
- QVERIFY((expr)); \
- } while (false)
-
-
-class tst_qmlimageprovider : public QObject
-{
- Q_OBJECT
-public:
- tst_qmlimageprovider()
- {
- }
-
-private slots:
- void imageSource();
- void imageSource_data();
- void removeProvider();
-
-private:
- QmlEngine engine;
-};
-
-class TestProvider : public QmlImageProvider
-{
-public:
- QImage request(const QString &id) {
- QImage image;
- image.load(SRCDIR "/data/" + id);
- return image;
- }
-};
-
-void tst_qmlimageprovider::imageSource_data()
-{
- QTest::addColumn<QString>("source");
- QTest::addColumn<QString>("error");
-
- QTest::newRow("exists") << "image://test/exists.png" << "";
- QTest::newRow("missing") << "image://test/no-such-file.png"
- << "\"Failed to get image from provider: image://test/no-such-file.png\" ";
- QTest::newRow("unknown provider") << "image://bogus/exists.png"
- << "\"Failed to get image from provider: image://bogus/exists.png\" ";
-}
-
-void tst_qmlimageprovider::imageSource()
-{
- QFETCH(QString, source);
- QFETCH(QString, error);
-
- if (!error.isEmpty())
- QTest::ignoreMessage(QtWarningMsg, error.toUtf8());
-
- engine.addImageProvider("test", new TestProvider);
- QVERIFY(engine.imageProvider("test") != 0);
-
- QString componentStr = "import Qt 4.6\nImage { source: \"" + source + "\" }";
- QmlComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsImage *obj = qobject_cast<QmlGraphicsImage*>(component.create());
- QVERIFY(obj != 0);
-
- TRY_WAIT(obj->status() == QmlGraphicsImage::Loading);
-
- QCOMPARE(obj->source(), QUrl(source));
-
- if (error.isEmpty()) {
- TRY_WAIT(obj->status() == QmlGraphicsImage::Ready);
- QCOMPARE(obj->width(), 100.);
- QCOMPARE(obj->height(), 100.);
- QCOMPARE(obj->fillMode(), QmlGraphicsImage::Stretch);
- QCOMPARE(obj->progress(), 1.0);
- } else {
- TRY_WAIT(obj->status() == QmlGraphicsImage::Error);
- }
-
- delete obj;
-}
-
-void tst_qmlimageprovider::removeProvider()
-{
- engine.addImageProvider("test2", new TestProvider);
- QVERIFY(engine.imageProvider("test2") != 0);
-
- // add provider, confirm it works
- QString componentStr = "import Qt 4.6\nImage { source: \"image://test2/exists1.png\" }";
- QmlComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsImage *obj = qobject_cast<QmlGraphicsImage*>(component.create());
- QVERIFY(obj != 0);
-
- TRY_WAIT(obj->status() == QmlGraphicsImage::Loading);
- TRY_WAIT(obj->status() == QmlGraphicsImage::Ready);
-
- QCOMPARE(obj->width(), 100.0);
-
- // remove the provider and confirm
- QString error("\"Failed to get image from provider: image://test2/exists2.png\" ");
- QTest::ignoreMessage(QtWarningMsg, error.toUtf8());
-
- engine.removeImageProvider("test2");
-
- obj->setSource(QUrl("image://test2/exists2.png"));
-
- TRY_WAIT(obj->status() == QmlGraphicsImage::Loading);
- TRY_WAIT(obj->status() == QmlGraphicsImage::Error);
-
- delete obj;
-}
-
-
-QTEST_MAIN(tst_qmlimageprovider)
-
-#include "tst_qmlimageprovider.moc"
diff --git a/tests/auto/declarative/qmlinfo/qmlinfo.pro b/tests/auto/declarative/qmlinfo/qmlinfo.pro
deleted file mode 100644
index dbebf92..0000000
--- a/tests/auto/declarative/qmlinfo/qmlinfo.pro
+++ /dev/null
@@ -1,7 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qmlinfo.cpp
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmlinfo/tst_qmlinfo.cpp b/tests/auto/declarative/qmlinfo/tst_qmlinfo.cpp
deleted file mode 100644
index e4da993..0000000
--- a/tests/auto/declarative/qmlinfo/tst_qmlinfo.cpp
+++ /dev/null
@@ -1,139 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qtest.h>
-#include <QmlEngine>
-#include <QmlComponent>
-#include <QPushButton>
-#include <QmlContext>
-#include <qmlinfo.h>
-
-class tst_qmlinfo : public QObject
-{
- Q_OBJECT
-public:
- tst_qmlinfo() {}
-
-private slots:
- void qmlObject();
- void nestedQmlObject();
- void nonQmlObject();
- void nullObject();
- void nonQmlContextedObject();
-
-private:
- QmlEngine engine;
-};
-
-inline QUrl TEST_FILE(const QString &filename)
-{
- return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename);
-}
-
-void tst_qmlinfo::qmlObject()
-{
- QmlComponent component(&engine, TEST_FILE("qmlObject.qml"));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QString message = "QML QObject_QML_0 (" + component.url().toString() + ":3:1) Test Message";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(message));
- qmlInfo(object) << "Test Message";
-
- QObject *nested = qvariant_cast<QObject *>(object->property("nested"));
- QVERIFY(nested != 0);
-
- message = "QML QtObject (" + component.url().toString() + ":6:13) Second Test Message";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(message));
- qmlInfo(nested) << "Second Test Message";
-}
-
-void tst_qmlinfo::nestedQmlObject()
-{
- QmlComponent component(&engine, TEST_FILE("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 = "QML NestedObject (" + component.url().toString() + ":5:13) Outer Object";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(message));
- qmlInfo(nested) << "Outer Object";
-
- message = "QML QtObject (" + TEST_FILE("NestedObject.qml").toString() + ":6:14) Inner Object";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(message));
- qmlInfo(nested2) << "Inner Object";
-}
-
-void tst_qmlinfo::nonQmlObject()
-{
- QObject object;
- QTest::ignoreMessage(QtWarningMsg, "QML QtObject (unknown location) Test Message");
- qmlInfo(&object) << "Test Message";
-
- QPushButton pbObject;
- QTest::ignoreMessage(QtWarningMsg, "QML QPushButton (unknown location) Test Message");
- qmlInfo(&pbObject) << "Test Message";
-}
-
-void tst_qmlinfo::nullObject()
-{
- QTest::ignoreMessage(QtWarningMsg, "QML (unknown location) Null Object Test Message");
- qmlInfo(0) << "Null Object Test Message";
-}
-
-void tst_qmlinfo::nonQmlContextedObject()
-{
- QObject object;
- QmlContext context(&engine);
- QmlEngine::setContextForObject(&object, &context);
- QTest::ignoreMessage(QtWarningMsg, "QML QtObject (unknown location) Test Message");
- qmlInfo(&object) << "Test Message";
-}
-
-QTEST_MAIN(tst_qmlinfo)
-
-#include "tst_qmlinfo.moc"
diff --git a/tests/auto/declarative/qmlinstruction/qmlinstruction.pro b/tests/auto/declarative/qmlinstruction/qmlinstruction.pro
deleted file mode 100644
index 41be488..0000000
--- a/tests/auto/declarative/qmlinstruction/qmlinstruction.pro
+++ /dev/null
@@ -1,6 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative script
-SOURCES += tst_qmlinstruction.cpp
-macx:CONFIG -= app_bundle
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmlinstruction/tst_qmlinstruction.cpp b/tests/auto/declarative/qmlinstruction/tst_qmlinstruction.cpp
deleted file mode 100644
index 38d024a..0000000
--- a/tests/auto/declarative/qmlinstruction/tst_qmlinstruction.cpp
+++ /dev/null
@@ -1,585 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qtest.h>
-#include <private/qmlcompiler_p.h>
-
-class tst_qmlinstruction : public QObject
-{
- Q_OBJECT
-public:
- tst_qmlinstruction() {}
-
-private slots:
- void dump();
-};
-
-static QStringList messages;
-static void msgHandler(QtMsgType, const char *msg)
-{
- messages << QLatin1String(msg);
-}
-
-void tst_qmlinstruction::dump()
-{
- QmlCompiledData *data = new QmlCompiledData(0);
- {
- QmlInstruction i;
- i.line = 0;
- i.type = QmlInstruction::Init;
- i.init.bindingsSize = 0;
- i.init.parserStatusSize = 3;
- i.init.contextCache = -1;
- i.init.compiledBinding = -1;
- data->bytecode << i;
- }
-
- {
- QmlCompiledData::TypeReference ref;
- ref.className = "Test";
- data->types << ref;
-
- QmlInstruction i;
- i.line = 1;
- i.type = QmlInstruction::CreateObject;
- i.create.type = 0;
- i.create.data = -1;
- i.create.bindingBits = -1;
- i.create.column = 10;
- data->bytecode << i;
- }
-
- {
- data->primitives << "testId";
-
- QmlInstruction i;
- i.line = 2;
- i.type = QmlInstruction::SetId;
- i.setId.value = 0;
- i.setId.index = 0;
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
- i.line = 3;
- i.type = QmlInstruction::SetDefault;
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
- i.line = 4;
- i.type = QmlInstruction::CreateComponent;
- i.createComponent.count = 3;
- i.createComponent.column = 4;
- i.createComponent.endLine = 14;
- i.createComponent.metaObject = 0;
-
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
- i.line = 5;
- i.type = QmlInstruction::StoreMetaObject;
- i.storeMeta.data = 3;
- i.storeMeta.aliasData = 6;
- i.storeMeta.propertyCache = 7;
-
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
- i.line = 6;
- i.type = QmlInstruction::StoreFloat;
- i.storeFloat.propertyIndex = 3;
- i.storeFloat.value = 11.3;
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
- i.line = 7;
- i.type = QmlInstruction::StoreDouble;
- i.storeDouble.propertyIndex = 4;
- i.storeDouble.value = 14.8;
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
- i.line = 8;
- i.type = QmlInstruction::StoreInteger;
- i.storeInteger.propertyIndex = 5;
- i.storeInteger.value = 9;
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
- i.line = 9;
- i.type = QmlInstruction::StoreBool;
- i.storeBool.propertyIndex = 6;
- i.storeBool.value = true;
-
- data->bytecode << i;
- }
-
- {
- data->primitives << "Test String";
- QmlInstruction i;
- i.line = 10;
- i.type = QmlInstruction::StoreString;
- i.storeString.propertyIndex = 7;
- i.storeString.value = 1;
- data->bytecode << i;
- }
-
- {
- data->primitives << "http://www.nokia.com";
- QmlInstruction i;
- i.line = 11;
- i.type = QmlInstruction::StoreUrl;
- i.storeUrl.propertyIndex = 8;
- i.storeUrl.value = 2;
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
- i.line = 12;
- i.type = QmlInstruction::StoreColor;
- i.storeColor.propertyIndex = 9;
- i.storeColor.value = 0xFF00FF00;
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
- i.line = 13;
- i.type = QmlInstruction::StoreDate;
- i.storeDate.propertyIndex = 10;
- i.storeDate.value = 9;
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
- i.line = 14;
- i.type = QmlInstruction::StoreTime;
- i.storeTime.propertyIndex = 11;
- i.storeTime.valueIndex = 33;
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
- i.line = 15;
- i.type = QmlInstruction::StoreDateTime;
- i.storeDateTime.propertyIndex = 12;
- i.storeDateTime.valueIndex = 44;
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
- i.line = 16;
- i.type = QmlInstruction::StorePoint;
- i.storeRealPair.propertyIndex = 13;
- i.storeRealPair.valueIndex = 3;
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
- i.line = 17;
- i.type = QmlInstruction::StorePointF;
- i.storeRealPair.propertyIndex = 14;
- i.storeRealPair.valueIndex = 9;
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
- i.line = 18;
- i.type = QmlInstruction::StoreSize;
- i.storeRealPair.propertyIndex = 15;
- i.storeRealPair.valueIndex = 8;
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
- i.line = 19;
- i.type = QmlInstruction::StoreSizeF;
- i.storeRealPair.propertyIndex = 16;
- i.storeRealPair.valueIndex = 99;
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
- i.line = 20;
- i.type = QmlInstruction::StoreRect;
- i.storeRect.propertyIndex = 17;
- i.storeRect.valueIndex = 2;
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
- i.line = 21;
- i.type = QmlInstruction::StoreRectF;
- i.storeRect.propertyIndex = 18;
- i.storeRect.valueIndex = 19;
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
- i.line = 22;
- i.type = QmlInstruction::StoreVector3D;
- i.storeVector3D.propertyIndex = 19;
- i.storeVector3D.valueIndex = 9;
- data->bytecode << i;
- }
-
- {
- data->primitives << "color(1, 1, 1, 1)";
- QmlInstruction i;
- i.line = 23;
- i.type = QmlInstruction::StoreVariant;
- i.storeString.propertyIndex = 20;
- i.storeString.value = 3;
-
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
- i.line = 24;
- i.type = QmlInstruction::StoreObject;
- i.storeObject.propertyIndex = 21;
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
- i.line = 25;
- i.type = QmlInstruction::StoreVariantObject;
- i.storeObject.propertyIndex = 22;
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
- i.line = 26;
- i.type = QmlInstruction::StoreInterface;
- i.storeObject.propertyIndex = 23;
- data->bytecode << i;
- }
-
- {
- data->primitives << "console.log(1921)";
-
- QmlInstruction i;
- i.line = 27;
- i.type = QmlInstruction::StoreSignal;
- i.storeSignal.signalIndex = 2;
- i.storeSignal.value = 4;
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
- i.line = 28;
- i.type = QmlInstruction::StoreScript;
- i.storeScript.value = 2;
- //i.storeScript.fileName = 18;
- //i.storeScript.lineNumber = 28;
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
- i.line = 29;
- i.type = QmlInstruction::StoreScriptString;
- i.storeScriptString.propertyIndex = 24;
- i.storeScriptString.value = 3;
- i.storeScriptString.scope = 1;
- data->bytecode << i;
- }
-
- {
- data->datas << "mySignal";
-
- QmlInstruction i;
- i.line = 30;
- i.type = QmlInstruction::AssignSignalObject;
- i.assignSignalObject.signal = 0;
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
- i.line = 31;
- i.type = QmlInstruction::AssignCustomType;
- i.assignCustomType.propertyIndex = 25;
- i.assignCustomType.valueIndex = 4;
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
- i.line = 32;
- i.type = QmlInstruction::StoreBinding;
- i.assignBinding.property = 26;
- i.assignBinding.value = 3;
- i.assignBinding.context = 2;
- i.assignBinding.owner = 0;
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
- i.line = 33;
- i.type = QmlInstruction::StoreCompiledBinding;
- i.assignBinding.property = 27;
- i.assignBinding.value = 2;
- i.assignBinding.context = 4;
- i.assignBinding.owner = 0;
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
- i.line = 34;
- i.type = QmlInstruction::StoreValueSource;
- i.assignValueSource.property = 29;
- i.assignValueSource.owner = 1;
- i.assignValueSource.castValue = 4;
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
- i.line = 35;
- i.type = QmlInstruction::StoreValueInterceptor;
- i.assignValueInterceptor.property = 30;
- i.assignValueInterceptor.owner = 2;
- i.assignValueInterceptor.castValue = -4;
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
- i.line = 36;
- i.type = QmlInstruction::BeginObject;
- i.begin.castValue = 4;
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
- i.line = 38;
- i.type = QmlInstruction::StoreObjectQList;
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
- i.line = 39;
- i.type = QmlInstruction::AssignObjectList;
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
- i.line = 40;
- i.type = QmlInstruction::FetchAttached;
- i.fetchAttached.id = 23;
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
- i.line = 42;
- i.type = QmlInstruction::FetchQList;
- i.fetch.property = 32;
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
- i.line = 43;
- i.type = QmlInstruction::FetchObject;
- i.fetch.property = 33;
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
- i.line = 44;
- i.type = QmlInstruction::FetchValueType;
- i.fetchValue.property = 34;
- i.fetchValue.type = 6;
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
- i.line = 45;
- i.type = QmlInstruction::PopFetchedObject;
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
- i.line = 46;
- i.type = QmlInstruction::PopQList;
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
- i.line = 47;
- i.type = QmlInstruction::PopValueType;
- i.fetchValue.property = 35;
- i.fetchValue.type = 8;
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
- i.line = 48;
- i.type = QmlInstruction::Defer;
- i.defer.deferCount = 7;
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
- i.line = -1;
- i.type = QmlInstruction::Defer;
- i.defer.deferCount = 7;
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
- i.line = 50;
- i.type = (QmlInstruction::Type)(QmlInstruction::Defer + 1); // Non-existant
- data->bytecode << i;
- }
-
- QStringList expect;
- expect
- << "Index\tLine\tOperation\t\tData1\tData2\tData3\tComments"
- << "-------------------------------------------------------------------------------"
- << "0\t\t0\tINIT\t\t\t0\t3\t-1\t-1"
- << "1\t\t1\tCREATE\t\t\t0\t\t\t\"Test\""
- << "2\t\t2\tSETID\t\t\t0\t\t\t\"testId\""
- << "3\t\t3\tSET_DEFAULT"
- << "4\t\t4\tCREATE_COMPONENT\t3"
- << "5\t\t5\tSTORE_META\t\t3"
- << "6\t\t6\tSTORE_FLOAT\t\t3\t11.3"
- << "7\t\t7\tSTORE_DOUBLE\t\t4\t14.8"
- << "8\t\t8\tSTORE_INTEGER\t\t5\t9"
- << "9\t\t9\tSTORE_BOOL\t\t6\ttrue"
- << "10\t\t10\tSTORE_STRING\t\t7\t1\t\t\"Test String\""
- << "11\t\t11\tSTORE_URL\t\t8\t2\t\t\"http://www.nokia.com\""
- << "12\t\t12\tSTORE_COLOR\t\t9\t\t\t\"ff00ff00\""
- << "13\t\t13\tSTORE_DATE\t\t10\t9"
- << "14\t\t14\tSTORE_TIME\t\t11\t33"
- << "15\t\t15\tSTORE_DATETIME\t\t12\t44"
- << "16\t\t16\tSTORE_POINT\t\t13\t3"
- << "17\t\t17\tSTORE_POINTF\t\t14\t9"
- << "18\t\t18\tSTORE_SIZE\t\t15\t8"
- << "19\t\t19\tSTORE_SIZEF\t\t16\t99"
- << "20\t\t20\tSTORE_RECT\t\t17\t2"
- << "21\t\t21\tSTORE_RECTF\t\t18\t19"
- << "22\t\t22\tSTORE_VECTOR3D\t\t19\t9"
- << "23\t\t23\tSTORE_VARIANT\t\t20\t3\t\t\"color(1, 1, 1, 1)\""
- << "24\t\t24\tSTORE_OBJECT\t\t21"
- << "25\t\t25\tSTORE_VARIANT_OBJECT\t22"
- << "26\t\t26\tSTORE_INTERFACE\t\t23"
- << "27\t\t27\tSTORE_SIGNAL\t\t2\t4\t\t\"console.log(1921)\""
- << "28\t\t28\tSTORE_SCRIPT\t\t2"
- << "29\t\t29\tSTORE_SCRIPT_STRING\t24\t3\t1"
- << "30\t\t30\tASSIGN_SIGNAL_OBJECT\t0\t\t\t\"mySignal\""
- << "31\t\t31\tASSIGN_CUSTOMTYPE\t25\t4"
- << "32\t\t32\tSTORE_BINDING\t26\t3\t2"
- << "33\t\t33\tSTORE_COMPILED_BINDING\t27\t2\t4"
- << "34\t\t34\tSTORE_VALUE_SOURCE\t29\t4"
- << "35\t\t35\tSTORE_VALUE_INTERCEPTOR\t30\t-4"
- << "36\t\t36\tBEGIN\t\t\t4"
- << "37\t\t38\tSTORE_OBJECT_QLIST"
- << "38\t\t39\tASSIGN_OBJECT_LIST"
- << "39\t\t40\tFETCH_ATTACHED\t\t23"
- << "40\t\t42\tFETCH_QLIST\t\t32"
- << "41\t\t43\tFETCH\t\t\t33"
- << "42\t\t44\tFETCH_VALUE\t\t34\t6"
- << "43\t\t45\tPOP"
- << "44\t\t46\tPOP_QLIST"
- << "45\t\t47\tPOP_VALUE\t\t35\t8"
- << "46\t\t48\tDEFER\t\t\t7"
- << "47\t\tNA\tDEFER\t\t\t7"
- << "48\t\t50\tXXX UNKOWN INSTRUCTION\t47"
- << "-------------------------------------------------------------------------------";
-
- 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();
-}
-
-QTEST_MAIN(tst_qmlinstruction)
-
-#include "tst_qmlinstruction.moc"
diff --git a/tests/auto/declarative/qmllanguage/data/component.5.errors.txt b/tests/auto/declarative/qmllanguage/data/component.5.errors.txt
deleted file mode 100644
index 5e88900..0000000
--- a/tests/auto/declarative/qmllanguage/data/component.5.errors.txt
+++ /dev/null
@@ -1 +0,0 @@
-4:5:Invalid component specification
diff --git a/tests/auto/declarative/qmllanguage/data/script.10.errors.txt b/tests/auto/declarative/qmllanguage/data/script.10.errors.txt
deleted file mode 100644
index 8299d23..0000000
--- a/tests/auto/declarative/qmllanguage/data/script.10.errors.txt
+++ /dev/null
@@ -1 +0,0 @@
-6:9:Invalid component specification
diff --git a/tests/auto/declarative/qmllanguage/data/script.12.errors.txt b/tests/auto/declarative/qmllanguage/data/script.12.errors.txt
deleted file mode 100644
index 85c8396..0000000
--- a/tests/auto/declarative/qmllanguage/data/script.12.errors.txt
+++ /dev/null
@@ -1 +0,0 @@
-4:5:QmlJS declaration outside Script element
diff --git a/tests/auto/declarative/qmllanguage/data/script.9.errors.txt b/tests/auto/declarative/qmllanguage/data/script.9.errors.txt
deleted file mode 100644
index dc1eb53..0000000
--- a/tests/auto/declarative/qmllanguage/data/script.9.errors.txt
+++ /dev/null
@@ -1 +0,0 @@
-5:9:Invalid component specification
diff --git a/tests/auto/declarative/qmllanguage/qmllanguage.pro b/tests/auto/declarative/qmllanguage/qmllanguage.pro
deleted file mode 100644
index d1876ef..0000000
--- a/tests/auto/declarative/qmllanguage/qmllanguage.pro
+++ /dev/null
@@ -1,14 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative
-QT += script network
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qmllanguage.cpp \
- testtypes.cpp
-HEADERS += testtypes.h
-
-INCLUDEPATH += ../shared/
-HEADERS += ../shared/testhttpserver.h
-SOURCES += ../shared/testhttpserver.cpp
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmllanguage/testtypes.cpp b/tests/auto/declarative/qmllanguage/testtypes.cpp
deleted file mode 100644
index a295054..0000000
--- a/tests/auto/declarative/qmllanguage/testtypes.cpp
+++ /dev/null
@@ -1,59 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include "testtypes.h"
-
-QML_DEFINE_INTERFACE(MyInterface);
-QML_DEFINE_TYPE(Test,1,0,MyQmlObject,MyQmlObject);
-QML_DEFINE_TYPE(Test,1,0,MyTypeObject,MyTypeObject);
-QML_DEFINE_TYPE(Test,1,0,MyContainer,MyContainer);
-QML_DEFINE_TYPE(Test,1,0,MyPropertyValueSource,MyPropertyValueSource);
-QML_DEFINE_TYPE(Test,1,0,MyDotPropertyObject,MyDotPropertyObject);
-QML_DEFINE_TYPE(Test,1,0,MyNamespacedType,MyNamespace::MyNamespacedType);
-QML_DEFINE_TYPE(Test,1,0,MySecondNamespacedType,MyNamespace::MySecondNamespacedType);
-QML_DEFINE_NOCREATE_TYPE(MyGroupedObject);
-
-QVariant myCustomVariantTypeConverter(const QString &data)
-{
- MyCustomVariantType rv;
- rv.a = data.toInt();
- return QVariant::fromValue(rv);
-}
-
diff --git a/tests/auto/declarative/qmllanguage/testtypes.h b/tests/auto/declarative/qmllanguage/testtypes.h
deleted file mode 100644
index 27b45e4..0000000
--- a/tests/auto/declarative/qmllanguage/testtypes.h
+++ /dev/null
@@ -1,545 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef 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 <QtDeclarative/qml.h>
-#include <QtDeclarative/qmlcomponent.h>
-#include <QtDeclarative/qmlparserstatus.h>
-#include <QtDeclarative/qmlpropertyvaluesource.h>
-#include <QtDeclarative/qmlscriptstring.h>
-
-QVariant myCustomVariantTypeConverter(const QString &data);
-
-class MyInterface
-{
-public:
- MyInterface() : id(913) {}
- int id;
-};
-Q_DECLARE_INTERFACE(MyInterface, "com.trolltech.Qt.Test.MyInterface");
-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)
- 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) { m_value = v; }
-
- int value2() const { return m_value2; }
- void setValue2(int v) { m_value2 = v; }
-
-private:
- int m_value;
- int m_value2;
-};
-
-class MyQmlObject : public QObject, public MyInterface, public QmlParserStatus
-{
- 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_INTERFACES(MyInterface QmlParserStatus)
-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; }
-public slots:
- void basicSlot() { qWarning("MyQmlObject::basicSlot"); }
- void basicSlotWithArgs(int v) { qWarning("MyQmlObject::basicSlotWithArgs(%d)", v); }
-
-signals:
- void basicSignal();
- void basicParameterizedSignal(int parameter);
-
-private:
- friend class tst_qmllanguage;
- int m_value;
- MyInterface *m_interface;
- MyQmlObject *m_qmlobject;
- MyCustomVariantType m_custom;
-};
-QML_DECLARE_TYPEINFO(MyQmlObject, QML_HAS_ATTACHED_PROPERTIES)
-QML_DECLARE_TYPE(MyQmlObject);
-
-class MyGroupedObject : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(QmlScriptString script READ script WRITE setScript);
-public:
- QmlScriptString script() const { return m_script; }
- void setScript(const QmlScriptString &s) { m_script = s; }
-
-private:
- QmlScriptString m_script;
-};
-
-QML_DECLARE_TYPE(MyGroupedObject);
-
-
-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(QmlComponent *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(QmlScriptString 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;
- }
-
- QmlComponent *componentPropertyValue;
- QmlComponent *componentProperty() const {
- return componentPropertyValue;
- }
- void setComponentProperty(QmlComponent *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;
- }
-
- QmlScriptString scriptPropertyValue;
- QmlScriptString scriptProperty() const {
- return scriptPropertyValue;
- }
- void setScriptProperty(const QmlScriptString &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)
-QML_DECLARE_TYPE(MyTypeObject);
-
-class MyContainer : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(QmlListProperty<QObject> children READ children)
- Q_PROPERTY(QmlListProperty<MyInterface> qlistInterfaces READ qlistInterfaces)
- Q_CLASSINFO("DefaultProperty", "children");
-public:
- MyContainer() {}
-
- QmlListProperty<QObject> children() { return QmlListProperty<QObject>(this, m_children); }
- QList<QObject *> *getChildren() { return &m_children; }
- QmlListProperty<MyInterface> qlistInterfaces() { return QmlListProperty<MyInterface>(this, m_interfaces); }
- QList<MyInterface *> *getQListInterfaces() { return &m_interfaces; }
-
- QList<QObject*> m_children;
- QList<MyInterface *> m_interfaces;
-};
-
-QML_DECLARE_TYPE(MyContainer);
-
-
-class MyPropertyValueSource : public QObject, public QmlPropertyValueSource
-{
- Q_OBJECT
- Q_INTERFACES(QmlPropertyValueSource)
-public:
- MyPropertyValueSource()
- : QmlPropertyValueSource() {}
-
- QmlMetaProperty prop;
- virtual void setTarget(const QmlMetaProperty &p)
- {
- prop = p;
- }
-};
-QML_DECLARE_TYPE(MyPropertyValueSource);
-
-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;
-};
-
-QML_DECLARE_TYPE(MyDotPropertyObject);
-
-namespace MyNamespace {
- class MyNamespacedType : public QObject
- {
- Q_OBJECT
- };
-
- class MySecondNamespacedType : public QObject
- {
- Q_OBJECT
- Q_PROPERTY(QmlListProperty<MyNamespace::MyNamespacedType> list READ list);
- public:
- QmlListProperty<MyNamespacedType> list() { return QmlListProperty<MyNamespacedType>(this, m_list); }
-
- private:
- QList<MyNamespacedType *> m_list;
- };
-}
-QML_DECLARE_TYPE(MyNamespace::MyNamespacedType);
-QML_DECLARE_TYPE(MyNamespace::MySecondNamespacedType);
-
-#endif // TESTTYPES_H
diff --git a/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp b/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp
deleted file mode 100644
index 4090e1d..0000000
--- a/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp
+++ /dev/null
@@ -1,1383 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtDeclarative/qmlengine.h>
-#include <QtDeclarative/qmlcomponent.h>
-#include <QtCore/qfile.h>
-#include <QtCore/qdebug.h>
-#include <QtCore/qfileinfo.h>
-#include <QtCore/qdir.h>
-#include <private/qmlmetaproperty_p.h>
-#include "testtypes.h"
-
-#include "../../../shared/util.h"
-
-/*
-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_qmllanguage : public QObject
-{
- Q_OBJECT
-public:
- tst_qmllanguage() {
- QmlMetaType::registerCustomStringConverter(qMetaTypeId<MyCustomVariantType>(), myCustomVariantTypeConverter);
- QFileInfo fileInfo(__FILE__);
- engine.addImportPath(fileInfo.absoluteDir().filePath(QLatin1String("data/lib")));
- }
-
-private slots:
- void initTestCase();
- void cleanupTestCase();
-
- void errors_data();
- void errors();
-
- void simpleObject();
- void simpleContainer();
- void interfaceProperty();
- void interfaceQList();
- void assignObjectToSignal();
- void assignObjectToVariant();
- void assignLiteralSignalProperty();
- void assignQmlComponent();
- void assignBasicTypes();
- void assignTypeExtremes();
- void assignCompositeToType();
- void customParserTypes();
- void rootAsQmlComponent();
- void inlineQmlComponents();
- void idProperty();
- 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 componentCompositeType();
- void i18n();
- void i18n_data();
- void onCompleted();
- void scriptString();
- void defaultPropertyListOrder();
- void declaredPropertyValues();
-
- 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 qmlAttachedPropertiesObjectMethod();
-
- // regression tests for crashes
- void crash1();
- void crash2();
-
-private:
- QmlEngine engine;
- void testType(const QString& qml, const QString& type);
-};
-
-#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 { \
- QFile file(QLatin1String(SRCDIR) + QLatin1String("/data/") + QLatin1String(errorfile)); \
- QVERIFY(file.open(QIODevice::ReadOnly)); \
- QByteArray data = file.readAll(); \
- file.close(); \
- QList<QByteArray> expected = data.split('\n'); \
- expected.removeAll(QByteArray("")); \
- QList<QmlError> errors = component.errors(); \
- QList<QByteArray> actual; \
- for (int ii = 0; ii < errors.count(); ++ii) { \
- const QmlError &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("QMLLANGUAGE_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)
-{
- QFileInfo fileInfo(__FILE__);
- return QUrl::fromLocalFile(fileInfo.absoluteDir().filePath(QLatin1String("data/") + filename));
-}
-
-inline QUrl TEST_FILE(const char *filename)
-{
- return TEST_FILE(QLatin1String(filename));
-}
-
-void tst_qmllanguage::initTestCase()
-{
- // 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());
- QVERIFY(in.open(QIODevice::ReadOnly));
- QFile out(TEST_FILE(QString::fromUtf8("I18nType\303\201\303\242\303\243\303\244\303\245.qml")).toLocalFile());
- QVERIFY(out.open(QIODevice::WriteOnly));
- out.write(in.readAll());
-}
-
-void tst_qmllanguage::cleanupTestCase()
-{
- QVERIFY(QFile::remove(TEST_FILE(QString::fromUtf8("I18nType\303\201\303\242\303\243\303\244\303\245.qml")).toLocalFile()));
-}
-
-void tst_qmllanguage::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("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("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("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("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("invalidImportID") << "invalidImportID.qml" << "invalidImportID.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("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.5") << "property.5.qml" << "property.5.errors.txt" << false;
-
- QTest::newRow("Script.1") << "script.1.qml" << "script.1.errors.txt" << false;
- QTest::newRow("Script.2") << "script.2.qml" << "script.2.errors.txt" << false;
- QTest::newRow("Script.3") << "script.3.qml" << "script.3.errors.txt" << false;
- QTest::newRow("Script.4") << "script.4.qml" << "script.4.errors.txt" << false;
- QTest::newRow("Script.5") << "script.5.qml" << "script.5.errors.txt" << false;
- QTest::newRow("Script.6") << "script.6.qml" << "script.6.errors.txt" << false;
- QTest::newRow("Script.7") << "script.7.qml" << "script.7.errors.txt" << false;
- QTest::newRow("Script.8") << "script.8.qml" << "script.8.errors.txt" << false;
- QTest::newRow("Script.9") << "script.9.qml" << "script.9.errors.txt" << false;
- QTest::newRow("Script.10") << "script.10.qml" << "script.10.errors.txt" << false;
- QTest::newRow("Script.11") << "script.11.qml" << "script.11.errors.txt" << false;
- QTest::newRow("Script.12") << "script.12.qml" << "script.12.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("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("nestedErrors") << "nestedErrors.qml" << "nestedErrors.errors.txt" << false;
- QTest::newRow("defaultGrouped") << "defaultGrouped.qml" << "defaultGrouped.errors.txt" << false;
- QTest::newRow("emptySignal") << "emptySignal.qml" << "emptySignal.errors.txt" << false;
- QTest::newRow("doubleSignal") << "doubleSignal.qml" << "doubleSignal.errors.txt" << false;
- QTest::newRow("invalidRoot") << "invalidRoot.qml" << "invalidRoot.errors.txt" << false;
- QTest::newRow("missingValueTypeProperty") << "missingValueTypeProperty.qml" << "missingValueTypeProperty.errors.txt" << false;
- QTest::newRow("objectValueTypeProperty") << "objectValueTypeProperty.qml" << "objectValueTypeProperty.errors.txt" << false;
-}
-
-
-void tst_qmllanguage::errors()
-{
- QFETCH(QString, file);
- QFETCH(QString, errorFile);
- QFETCH(bool, create);
-
- if (file == "invalidID.6.qml")
- QSKIP("Test disabled until we strictly disallow ids from beginning with uppercase letters", SkipSingle);
-
- QmlComponent component(&engine, TEST_FILE(file));
-
- if(create) {
- QObject *object = component.create();
- QVERIFY(object == 0);
- }
-
- VERIFY_ERRORS(errorFile.toLatin1().constData());
-}
-
-void tst_qmllanguage::simpleObject()
-{
- QmlComponent component(&engine, TEST_FILE("simpleObject.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
-}
-
-void tst_qmllanguage::simpleContainer()
-{
- QmlComponent 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_qmllanguage::interfaceProperty()
-{
- QmlComponent 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_qmllanguage::interfaceQList()
-{
- QmlComponent 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_qmllanguage::assignObjectToSignal()
-{
- QmlComponent 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_qmllanguage::assignObjectToVariant()
-{
- QmlComponent 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_qmllanguage::assignLiteralSignalProperty()
-{
- QmlComponent 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_qmllanguage::assignQmlComponent()
-{
- QmlComponent 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_qmllanguage::assignBasicTypes()
-{
- QmlComponent 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((float)-10.1, (float)12.3));
- QCOMPARE(object->sizeProperty(), QSize(99, 13));
- QCOMPARE(object->sizeFProperty(), QSizeF((float)0.1, (float)0.2));
- QCOMPARE(object->rectProperty(), QRect(9, 7, 100, 200));
- QCOMPARE(object->rectFProperty(), QRectF((float)1000.1, (float)-10.9, (float)400, (float)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")));
- 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_qmllanguage::assignTypeExtremes()
-{
- QmlComponent 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_qmllanguage::assignCompositeToType()
-{
- QmlComponent component(&engine, TEST_FILE("assignCompositeToType.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
-}
-
-// Tests that custom parser types can be instantiated
-void tst_qmllanguage::customParserTypes()
-{
- QmlComponent 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_qmllanguage::rootAsQmlComponent()
-{
- QmlComponent 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_qmllanguage::inlineQmlComponents()
-{
- QmlComponent component(&engine, TEST_FILE("inlineQmlComponents.qml"));
- VERIFY_ERRORS(0);
- MyContainer *object = qobject_cast<MyContainer *>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->getChildren()->count(), 1);
- QmlComponent *comp = qobject_cast<QmlComponent *>(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_qmllanguage::idProperty()
-{
- QmlComponent 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 that signals can be assigned to
-void tst_qmllanguage::assignSignal()
-{
- QmlComponent 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_qmllanguage::dynamicProperties()
-{
- QmlComponent 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!"));
- QCOMPARE(object->property("variantProperty"), QVariant(12));
-}
-
-// Test that nested types can use dynamic properties
-void tst_qmllanguage::dynamicPropertiesNested()
-{
- QmlComponent 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_qmllanguage::listProperties()
-{
- QmlComponent 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_qmllanguage::dynamicObjectProperties()
-{
- QmlComponent 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));
-}
-
-// Tests the declaration of dynamic signals and slots
-void tst_qmllanguage::dynamicSignalsAndSlots()
-{
- QTest::ignoreMessage(QtDebugMsg, "1921");
-
- QmlComponent 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_qmllanguage::simpleBindings()
-{
- QmlComponent 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_qmllanguage::autoComponentCreation()
-{
- QmlComponent 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_qmllanguage::propertyValueSource()
-{
- {
- QmlComponent 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<QmlPropertyValueSource *>(child))
- valueSources.append(child);
- }
-
- QCOMPARE(valueSources.count(), 1);
- MyPropertyValueSource *valueSource =
- qobject_cast<MyPropertyValueSource *>(valueSources.at(0));
- QVERIFY(valueSource != 0);
- QCOMPARE(valueSource->prop.object(), object);
- QCOMPARE(valueSource->prop.name(), QString(QLatin1String("intProperty")));
- }
-
- {
- QmlComponent 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<QmlPropertyValueSource *>(child))
- valueSources.append(child);
- }
-
- QCOMPARE(valueSources.count(), 1);
- MyPropertyValueSource *valueSource =
- qobject_cast<MyPropertyValueSource *>(valueSources.at(0));
- QVERIFY(valueSource != 0);
- QCOMPARE(valueSource->prop.object(), object);
- QCOMPARE(valueSource->prop.name(), QString(QLatin1String("intProperty")));
- }
-}
-
-void tst_qmllanguage::attachedProperties()
-{
- QmlComponent 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_qmllanguage::dynamicObjects()
-{
- QmlComponent 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_qmllanguage::customVariantTypes()
-{
- QmlComponent 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_qmllanguage::valueTypes()
-{
- QmlComponent component(&engine, TEST_FILE("valueTypes.qml"));
- VERIFY_ERRORS(0);
-
- QString message = QLatin1String("QML MyTypeObject (") + component.url().toString() +
- QLatin1String(":2:1) 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
- QmlMetaProperty p = QmlMetaProperty::createProperty(object, "rectProperty.x");
- QCOMPARE(p.read(), QVariant(12));
- p.write(13);
- QCOMPARE(p.read(), QVariant(13));
-
- quint32 r = QmlMetaPropertyPrivate::saveValueType(p.coreIndex(), p.valueTypeCoreIndex());
- QmlMetaProperty p2;
- QmlMetaPropertyPrivate::restore(p2, r, object);
- QCOMPARE(p2.read(), QVariant(13));
-#endif
-}
-
-void tst_qmllanguage::cppnamespace()
-{
- {
- QmlComponent component(&engine, TEST_FILE("cppnamespace.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
- delete object;
- }
-
- {
- QmlComponent component(&engine, TEST_FILE("cppnamespace.2.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
- delete object;
- }
-}
-
-void tst_qmllanguage::aliasProperties()
-{
- // Simple "int" alias
- {
- QmlComponent 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 throught alias
- object->setProperty("valueAlias", QVariant(19));
- QCOMPARE(object->property("valueAlias").toInt(), 19);
- QCOMPARE(object->property("value").toInt(), 19);
-
- delete object;
- }
-
- // Complex object alias
- {
- QmlComponent 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
- {
- QmlComponent 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
- {
- QmlComponent 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
- {
- QmlComponent 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
- {
- QmlComponent 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
- {
- QmlComponent 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
- {
- QmlComponent 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
- {
- QmlComponent 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;
- }
-}
-
-// Test that the root element in a composite type can be a Component
-void tst_qmllanguage::componentCompositeType()
-{
- QmlComponent 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_qmllanguage::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_qmllanguage::i18n()
-{
- QFETCH(QString, file);
- QFETCH(QString, stringProperty);
- QmlComponent 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_qmllanguage::onCompleted()
-{
- QmlComponent 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 assignments to QmlScriptString properties work
-void tst_qmllanguage::scriptString()
-{
- QmlComponent 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(), 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(), object);
- QCOMPARE(object->grouped()->script().context(), qmlContext(object));
-}
-
-// Check that default property assignments are correctly spliced into explicit
-// property assignments
-void tst_qmllanguage::defaultPropertyListOrder()
-{
- QmlComponent 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_qmllanguage::declaredPropertyValues()
-{
- QmlComponent component(&engine, TEST_FILE("declaredPropertyValues.qml"));
- QEXPECT_FAIL("", "QTBUG-7860", Abort);
- VERIFY_ERRORS(0);
-}
-
-// Check that first child of qml is of given type. Empty type insists on error.
-void tst_qmllanguage::testType(const QString& qml, const QString& type)
-{
- QmlComponent 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());
- } else {
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
- QCOMPARE(QString(object->metaObject()->className()), type);
- }
-}
-
-QML_DECLARE_TYPE(TestType)
-QML_DECLARE_TYPE(TestType2)
-
-QML_DEFINE_TYPE(com.nokia.Test, 0, 0, TestTP, TestType)
-QML_DEFINE_TYPE(com.nokia.Test, 1, 0, Test, TestType)
-QML_DEFINE_TYPE(com.nokia.Test, 1, 5, Test, TestType)
-QML_DEFINE_TYPE(com.nokia.Test, 1, 8, Test, TestType2)
-QML_DEFINE_TYPE(com.nokia.Test, 1, 9, OldTest, TestType)
-QML_DEFINE_TYPE(com.nokia.Test, 1, 12, Test, TestType2)
-
-// Import tests (QT-558)
-
-void tst_qmllanguage::importsBuiltin_data()
-{
- // QT-610
-
- QTest::addColumn<QString>("qml");
- QTest::addColumn<QString>("type");
-
- // import built-ins
- QTest::newRow("missing import")
- << "Test {}"
- << "";
- QTest::newRow("not in version 0.0")
- << "import com.nokia.Test 0.0\n"
- "Test {}"
- << "";
- 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 {}"
- << "";
- 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 {}"
- << "";
- 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 {}"
- << "TestType2";
- QTest::newRow("multiversion 2")
- << "import com.nokia.Test 1.11\n"
- "import com.nokia.Test 1.12\n"
- "OldTest {}"
- << "TestType";
- 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_qmllanguage::importsBuiltin()
-{
- QFETCH(QString, qml);
- QFETCH(QString, type);
- testType(qml,type);
-}
-
-void tst_qmllanguage::importsLocal_data()
-{
- QTest::addColumn<QString>("qml");
- QTest::addColumn<QString>("type");
-
- // import locals
- QTest::newRow("local import")
- << "import \"subdir\"\n" // QT-613
- "Test {}"
- << "QmlGraphicsRectangle";
- QTest::newRow("local import second")
- << "import Qt 4.6\nimport \"subdir\"\n"
- "Test {}"
- << "QmlGraphicsRectangle";
- QTest::newRow("local import subsubdir")
- << "import Qt 4.6\nimport \"subdir/subsubdir\"\n"
- "SubTest {}"
- << "QmlGraphicsRectangle";
- QTest::newRow("local import QTBUG-7721 A")
- << "subdir.Test {}" // no longer allowed (QTBUG-7721)
- << "";
- QTest::newRow("local import QTBUG-7721 B")
- << "import \"subdir\" as X\n"
- "X.subsubdir.SubTest {}" // no longer allowed (QTBUG-7721)
- << "";
- QTest::newRow("local import as")
- << "import \"subdir\" as T\n"
- "T.Test {}"
- << "QmlGraphicsRectangle";
- QTest::newRow("wrong local import as")
- << "import \"subdir\" as T\n"
- "Test {}"
- << "";
- QTest::newRow("library precedence over local import")
- << "import \"subdir\"\n"
- "import com.nokia.Test 1.0\n"
- "Test {}"
- << "TestType";
-}
-
-void tst_qmllanguage::importsLocal()
-{
- QFETCH(QString, qml);
- QFETCH(QString, type);
- testType(qml,type);
-}
-
-void tst_qmllanguage::importsRemote_data()
-{
- QTest::addColumn<QString>("qml");
- QTest::addColumn<QString>("type");
-
- QString serverdir = "http://127.0.0.1:14445/qtest/declarative/qmllanguage";
-
- QTest::newRow("remote import") << "import \""+serverdir+"\"\nTest {}" << "QmlGraphicsRectangle";
- QTest::newRow("remote import with subdir") << "import \""+serverdir+"\"\nTestSubDir {}" << "QmlGraphicsText";
- QTest::newRow("remote import with local") << "import \""+serverdir+"\"\nTestLocal {}" << "QmlGraphicsImage";
-}
-
-#include "testhttpserver.h"
-
-void tst_qmllanguage::importsRemote()
-{
- QFETCH(QString, qml);
- QFETCH(QString, type);
-
- TestHTTPServer server(14445);
- server.serveDirectory(SRCDIR);
-
- testType(qml,type);
-}
-
-void tst_qmllanguage::importsInstalled_data()
-{
- // QT-610
-
- QTest::addColumn<QString>("qml");
- QTest::addColumn<QString>("type");
-
- // import installed
- QTest::newRow("installed import 0")
- << "import com.nokia.installedtest 0.0\n"
- "InstalledTestTP {}"
- << "QmlGraphicsRectangle";
- QTest::newRow("installed import 0 as TP")
- << "import com.nokia.installedtest 0.0 as TP\n"
- "TP.InstalledTestTP {}"
- << "QmlGraphicsRectangle";
- QTest::newRow("installed import 1")
- << "import com.nokia.installedtest 1.0\n"
- "InstalledTest {}"
- << "QmlGraphicsRectangle";
- QTest::newRow("installed import 2")
- << "import com.nokia.installedtest 1.3\n"
- "InstalledTest {}"
- << "QmlGraphicsRectangle";
- QTest::newRow("installed import 3")
- << "import com.nokia.installedtest 1.4\n"
- "InstalledTest {}"
- << "QmlGraphicsText";
- QTest::newRow("installed import 4")
- << "import com.nokia.installedtest 1.10\n"
- "InstalledTest {}"
- << "QmlGraphicsText";
- QTest::newRow("installed import visibility") // QT-614
- << "import com.nokia.installedtest 1.4\n"
- "PrivateType {}"
- << "";
-}
-
-void tst_qmllanguage::importsInstalled()
-{
- QFETCH(QString, qml);
- QFETCH(QString, type);
- testType(qml,type);
-}
-
-
-void tst_qmllanguage::importsOrder_data()
-{
- QTest::addColumn<QString>("qml");
- QTest::addColumn<QString>("type");
-
- QTest::newRow("installed import overrides 1") <<
- "import com.nokia.installedtest 1.0\n"
- "import com.nokia.installedtest 1.4\n"
- "InstalledTest {}"
- << "QmlGraphicsText";
- QTest::newRow("installed import overrides 2") <<
- "import com.nokia.installedtest 1.4\n"
- "import com.nokia.installedtest 1.0\n"
- "InstalledTest {}"
- << "QmlGraphicsRectangle";
- 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 {}"
- << "QmlGraphicsText";
- 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 {}"
- << "QmlGraphicsRectangle";
-
- QTest::newRow("installed import versus builtin 1") <<
- "import com.nokia.installedtest 1.5\n"
- "import Qt 4.6\n"
- "Rectangle {}"
- << "QmlGraphicsRectangle";
- QTest::newRow("installed import versus builtin 2") <<
- "import Qt 4.6\n"
- "import com.nokia.installedtest 1.5\n"
- "Rectangle {}"
- << "QmlGraphicsText";
- QTest::newRow("namespaces cannot be overridden by types 1") <<
- "import Qt 4.6 as Rectangle\n"
- "import com.nokia.installedtest 1.5\n"
- "Rectangle {}"
- << "";
- QTest::newRow("namespaces cannot be overridden by types 2") <<
- "import Qt 4.6 as Rectangle\n"
- "import com.nokia.installedtest 1.5\n"
- "Rectangle.Image {}"
- << "QmlGraphicsImage";
-}
-
-void tst_qmllanguage::importsOrder()
-{
- QFETCH(QString, qml);
- QFETCH(QString, type);
- testType(qml,type);
-}
-
-void tst_qmllanguage::qmlAttachedPropertiesObjectMethod()
-{
- QObject object;
-
- QCOMPARE(qmlAttachedPropertiesObject<MyQmlObject>(&object, false), (QObject *)0);
- QCOMPARE(qmlAttachedPropertiesObject<MyQmlObject>(&object, true), (QObject *)0);
-
- {
- QmlComponent 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);
- }
-
- {
- QmlComponent 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_qmllanguage::crash1()
-{
- QmlComponent component(&engine);
- component.setData("import Qt 4.6\nComponent {}", QUrl());
-}
-
-void tst_qmllanguage::crash2()
-{
- QmlComponent component(&engine, TEST_FILE("crash2.qml"));
-}
-
-QTEST_MAIN(tst_qmllanguage)
-
-#include "tst_qmllanguage.moc"
diff --git a/tests/auto/declarative/qmllist/qmllist.pro b/tests/auto/declarative/qmllist/qmllist.pro
deleted file mode 100644
index b2145ed..0000000
--- a/tests/auto/declarative/qmllist/qmllist.pro
+++ /dev/null
@@ -1,5 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qmllist.cpp
diff --git a/tests/auto/declarative/qmllist/tst_qmllist.cpp b/tests/auto/declarative/qmllist/tst_qmllist.cpp
deleted file mode 100644
index 76def1c..0000000
--- a/tests/auto/declarative/qmllist/tst_qmllist.cpp
+++ /dev/null
@@ -1,574 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qtest.h>
-#include <QUrl>
-#include <QFileInfo>
-#include <QDir>
-#include <QmlEngine>
-#include <QmlComponent>
-#include <QtDeclarative/qml.h>
-#include <QtDeclarative/qmlprivate.h>
-#include <QDebug>
-
-inline QUrl TEST_FILE(const QString &filename)
-{
- QFileInfo fileInfo(__FILE__);
- return QUrl::fromLocalFile(fileInfo.absoluteDir().filePath("data/" + filename));
-}
-
-inline QUrl TEST_FILE(const char *filename)
-{
- return TEST_FILE(QLatin1String(filename));
-}
-
-class tst_QmlList : public QObject
-{
- Q_OBJECT
-public:
- tst_QmlList() {}
-
-private slots:
- 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(QmlListProperty<TestType> data READ dataProperty);
- Q_PROPERTY(int intProperty READ intProperty);
-
-public:
- TestType() : property(this, data) {}
- QmlListProperty<TestType> dataProperty() { return property; }
- int intProperty() const { return 10; }
-
- QList<TestType *> data;
- QmlListProperty<TestType> property;
-};
-QML_DECLARE_TYPE(TestType);
-QML_DEFINE_NOCREATE_TYPE(TestType);
-
-void tst_QmlList::qmllistreference()
-{
- TestType tt;
-
- QmlListReference r(&tt, "data");
- QVERIFY(r.isValid() == true);
- QCOMPARE(r.count(), 0);
-
- tt.data.append(&tt);
- QCOMPARE(r.count(), 1);
-}
-
-void tst_QmlList::qmllistreference_invalid()
-{
- TestType tt;
-
- // Invalid
- {
- QmlListReference 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
- {
- QmlListReference 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
- {
- QmlListReference 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_QmlList::isValid()
-{
- TestType *tt = new TestType;
-
- {
- QmlListReference ref;
- QVERIFY(ref.isValid() == false);
- }
-
- {
- QmlListReference ref(tt, "blah");
- QVERIFY(ref.isValid() == false);
- }
-
- {
- QmlListReference ref(tt, "data");
- QVERIFY(ref.isValid() == true);
- delete tt;
- QVERIFY(ref.isValid() == false);
- }
-}
-
-void tst_QmlList::object()
-{
- TestType *tt = new TestType;
-
- {
- QmlListReference ref;
- QVERIFY(ref.object() == 0);
- }
-
- {
- QmlListReference ref(tt, "blah");
- QVERIFY(ref.object() == 0);
- }
-
- {
- QmlListReference ref(tt, "data");
- QVERIFY(ref.object() == tt);
- delete tt;
- QVERIFY(ref.object() == 0);
- }
-}
-
-void tst_QmlList::listElementType()
-{
- TestType *tt = new TestType;
-
- {
- QmlListReference ref;
- QVERIFY(ref.listElementType() == 0);
- }
-
- {
- QmlListReference ref(tt, "blah");
- QVERIFY(ref.listElementType() == 0);
- }
-
- {
- QmlListReference ref(tt, "data");
- QVERIFY(ref.listElementType() == &TestType::staticMetaObject);
- delete tt;
- QVERIFY(ref.listElementType() == 0);
- }
-}
-
-void tst_QmlList::canAppend()
-{
- TestType *tt = new TestType;
-
- {
- QmlListReference ref;
- QVERIFY(ref.canAppend() == false);
- }
-
- {
- QmlListReference ref(tt, "blah");
- QVERIFY(ref.canAppend() == false);
- }
-
- {
- QmlListReference ref(tt, "data");
- QVERIFY(ref.canAppend() == true);
- delete tt;
- QVERIFY(ref.canAppend() == false);
- }
-
- {
- TestType tt;
- tt.property.append = 0;
- QmlListReference ref(&tt, "data");
- QVERIFY(ref.canAppend() == false);
- }
-}
-
-void tst_QmlList::canAt()
-{
- TestType *tt = new TestType;
-
- {
- QmlListReference ref;
- QVERIFY(ref.canAt() == false);
- }
-
- {
- QmlListReference ref(tt, "blah");
- QVERIFY(ref.canAt() == false);
- }
-
- {
- QmlListReference ref(tt, "data");
- QVERIFY(ref.canAt() == true);
- delete tt;
- QVERIFY(ref.canAt() == false);
- }
-
- {
- TestType tt;
- tt.property.at = 0;
- QmlListReference ref(&tt, "data");
- QVERIFY(ref.canAt() == false);
- }
-}
-
-void tst_QmlList::canClear()
-{
- TestType *tt = new TestType;
-
- {
- QmlListReference ref;
- QVERIFY(ref.canClear() == false);
- }
-
- {
- QmlListReference ref(tt, "blah");
- QVERIFY(ref.canClear() == false);
- }
-
- {
- QmlListReference ref(tt, "data");
- QVERIFY(ref.canClear() == true);
- delete tt;
- QVERIFY(ref.canClear() == false);
- }
-
- {
- TestType tt;
- tt.property.clear = 0;
- QmlListReference ref(&tt, "data");
- QVERIFY(ref.canClear() == false);
- }
-}
-
-void tst_QmlList::canCount()
-{
- TestType *tt = new TestType;
-
- {
- QmlListReference ref;
- QVERIFY(ref.canCount() == false);
- }
-
- {
- QmlListReference ref(tt, "blah");
- QVERIFY(ref.canCount() == false);
- }
-
- {
- QmlListReference ref(tt, "data");
- QVERIFY(ref.canCount() == true);
- delete tt;
- QVERIFY(ref.canCount() == false);
- }
-
- {
- TestType tt;
- tt.property.count = 0;
- QmlListReference ref(&tt, "data");
- QVERIFY(ref.canCount() == false);
- }
-}
-
-void tst_QmlList::append()
-{
- TestType *tt = new TestType;
- QObject object;
-
- {
- QmlListReference ref;
- QVERIFY(ref.append(tt) == false);
- }
-
- {
- QmlListReference ref(tt, "blah");
- QVERIFY(ref.append(tt) == false);
- }
-
- {
- QmlListReference 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;
- QmlListReference ref(&tt, "data");
- QVERIFY(ref.append(&tt) == false);
- }
-}
-
-void tst_QmlList::at()
-{
- TestType *tt = new TestType;
- tt->data.append(tt);
- tt->data.append(0);
- tt->data.append(tt);
-
- {
- QmlListReference ref;
- QVERIFY(ref.at(0) == 0);
- }
-
- {
- QmlListReference ref(tt, "blah");
- QVERIFY(ref.at(0) == 0);
- }
-
- {
- QmlListReference 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;
- QmlListReference ref(&tt, "data");
- QVERIFY(ref.at(0) == 0);
- }
-}
-
-void tst_QmlList::clear()
-{
- TestType *tt = new TestType;
- tt->data.append(tt);
- tt->data.append(0);
- tt->data.append(tt);
-
- {
- QmlListReference ref;
- QVERIFY(ref.clear() == false);
- }
-
- {
- QmlListReference ref(tt, "blah");
- QVERIFY(ref.clear() == false);
- }
-
- {
- QmlListReference ref(tt, "data");
- QVERIFY(ref.clear() == true);
- QVERIFY(tt->data.count() == 0);
- delete tt;
- QVERIFY(ref.clear() == false);
- }
-
- {
- TestType tt;
- tt.property.clear = 0;
- QmlListReference ref(&tt, "data");
- QVERIFY(ref.clear() == false);
- }
-}
-
-void tst_QmlList::count()
-{
- TestType *tt = new TestType;
- tt->data.append(tt);
- tt->data.append(0);
- tt->data.append(tt);
-
- {
- QmlListReference ref;
- QVERIFY(ref.count() == 0);
- }
-
- {
- QmlListReference ref(tt, "blah");
- QVERIFY(ref.count() == 0);
- }
-
- {
- QmlListReference 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;
- QmlListReference ref(&tt, "data");
- QVERIFY(ref.count() == 0);
- }
-}
-
-void tst_QmlList::copy()
-{
- TestType tt;
- tt.data.append(&tt);
- tt.data.append(0);
- tt.data.append(&tt);
-
- QmlListReference *r1 = new QmlListReference(&tt, "data");
- QVERIFY(r1->count() == 3);
-
- QmlListReference r2(*r1);
- QmlListReference 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_QmlList::qmlmetaproperty()
-{
- TestType tt;
- tt.data.append(&tt);
- tt.data.append(0);
- tt.data.append(&tt);
-
- QmlMetaProperty prop(&tt, QLatin1String("data"));
- QVariant v = prop.read();
- QVERIFY(v.userType() == qMetaTypeId<QmlListReference>());
- QmlListReference ref = qvariant_cast<QmlListReference>(v);
- QVERIFY(ref.count() == 3);
- QVERIFY(ref.listElementType() == &TestType::staticMetaObject);
-}
-
-void tst_QmlList::engineTypes()
-{
- QmlEngine engine;
- QmlComponent component(&engine, TEST_FILE("engineTypes.qml"));
-
- QObject *o = component.create();
- QVERIFY(o);
-
- QmlMetaProperty p1(o, QLatin1String("myList"));
- QVERIFY(p1.propertyCategory() == QmlMetaProperty::Normal);
-
- QmlMetaProperty p2(o, QLatin1String("myList"), engine.rootContext());
- QVERIFY(p2.propertyCategory() == QmlMetaProperty::List);
- QVariant v = p2.read();
- QVERIFY(v.userType() == qMetaTypeId<QmlListReference>());
- QmlListReference ref = qvariant_cast<QmlListReference>(v);
- QVERIFY(ref.count() == 2);
- QVERIFY(ref.listElementType());
- QVERIFY(ref.listElementType() != &QObject::staticMetaObject);
-
- delete o;
-}
-
-void tst_QmlList::variantToList()
-{
- QmlEngine engine;
- QmlComponent component(&engine, TEST_FILE("variantToList.qml"));
-
- QObject *o = component.create();
- QVERIFY(o);
-
- QVERIFY(o->property("value").userType() == qMetaTypeId<QmlListReference>());
- QCOMPARE(o->property("test").toInt(), 1);
-
- delete o;
-}
-
-QTEST_MAIN(tst_QmlList)
-
-#include "tst_qmllist.moc"
diff --git a/tests/auto/declarative/qmllistmodel/qmllistmodel.pro b/tests/auto/declarative/qmllistmodel/qmllistmodel.pro
deleted file mode 100644
index 60b0c4b..0000000
--- a/tests/auto/declarative/qmllistmodel/qmllistmodel.pro
+++ /dev/null
@@ -1,6 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative
-QT += script
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qmllistmodel.cpp
diff --git a/tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp b/tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp
deleted file mode 100644
index e70c7f1..0000000
--- a/tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp
+++ /dev/null
@@ -1,338 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtDeclarative/private/qmllistmodel_p.h>
-#include <QtDeclarative/private/qmlexpression_p.h>
-#include <QmlComponent>
-#include <QDebug>
-
-class tst_QmlListModel : public QObject
-{
- Q_OBJECT
-public:
- tst_QmlListModel() {}
-
-private slots:
- void static_types();
- void static_types_data();
- void static_i18n();
- void static_nestedElements();
- void static_nestedElements_data();
- void dynamic_data();
- void dynamic();
- void error_data();
- void error();
-};
-
-void tst_QmlListModel::static_i18n()
-{
- QString expect = QString::fromUtf8("na\303\257ve");
- QString componentStr = "import Qt 4.6\nListModel { ListElement { prop1: \""+expect+"\" } }";
- QmlEngine engine;
- QmlComponent component(&engine);
- component.setData(componentStr.toUtf8(), QUrl::fromLocalFile(""));
- QmlListModel *obj = qobject_cast<QmlListModel*>(component.create());
- QVERIFY(obj != 0);
- QString prop = obj->get(0).property(QLatin1String("prop1")).toString();
- QCOMPARE(prop,expect);
- delete obj;
-}
-
-void tst_QmlListModel::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 Qt 4.6\n"
- "ListModel {\n"
- " ListElement {\n"
- " attributes: [\n";
- componentStr += elementsStr.toUtf8().constData();
- componentStr +=
- " ]\n"
- " }\n"
- "}";
-
- QmlEngine engine;
- QmlComponent component(&engine);
- component.setData(componentStr.toUtf8(), QUrl::fromLocalFile(""));
-
- QmlListModel *obj = qobject_cast<QmlListModel*>(component.create());
- QVERIFY(obj != 0);
-
- QScriptValue prop = obj->get(0).property(QLatin1String("attributes")).property(QLatin1String("count"));
- QVERIFY(prop.isNumber());
- QCOMPARE(prop.toInt32(), qint32(elementCount));
-
- delete obj;
-}
-
-void tst_QmlListModel::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_QmlListModel::dynamic_data()
-{
- QTest::addColumn<QString>("script");
- QTest::addColumn<int>("result");
- QTest::addColumn<QString>("warning");
-
- // Simple flat model
-
- QTest::newRow("count") << "count" << 0 << "";
-
- QTest::newRow("get1") << "{get(0)}" << 0 << "QML ListModel (unknown location) get: index 0 out of range";
- QTest::newRow("get2") << "{get(-1)}" << 0 << "QML ListModel (unknown location) get: index -1 out of range";
-
- QTest::newRow("append1") << "{append({'foo':123});count}" << 1 << "";
- QTest::newRow("append2") << "{append({'foo':123,'bar':456});count}" << 1 << "";
- QTest::newRow("append3a") << "{append({'foo':123});append({'foo':456});get(0).foo}" << 123 << "";
- QTest::newRow("append3b") << "{append({'foo':123});append({'foo':456});get(1).foo}" << 456 << "";
- QTest::newRow("append4a") << "{append(123)}" << 0 << "QML ListModel (unknown location) append: value is not an object";
- QTest::newRow("append4b") << "{append([1,2,3])}" << 0 << "QML ListModel (unknown location) append: value is not an object";
-
- QTest::newRow("clear1") << "{append({'foo':456});clear();count}" << 0 << "";
- QTest::newRow("clear2") << "{append({'foo':123});append({'foo':456});clear();count}" << 0 << "";
- QTest::newRow("clear2") << "{append({'foo':123});clear();get(0).foo}" << 0 << "QML ListModel (unknown location) get: index 0 out of range";
-
- QTest::newRow("remove1") << "{append({'foo':123});remove(0);count}" << 0 << "";
- QTest::newRow("remove2a") << "{append({'foo':123});append({'foo':456});remove(0);count}" << 1 << "";
- QTest::newRow("remove2b") << "{append({'foo':123});append({'foo':456});remove(0);get(0).foo}" << 456 << "";
- QTest::newRow("remove2c") << "{append({'foo':123});append({'foo':456});remove(1);get(0).foo}" << 123 << "";
- QTest::newRow("remove3") << "{append({'foo':123});remove(0);get(0).foo}" << 0 << "QML ListModel (unknown location) get: index 0 out of range";
- QTest::newRow("remove3a") << "{append({'foo':123});remove(-1)}" << 0 << "QML ListModel (unknown location) remove: index -1 out of range";
- QTest::newRow("remove4a") << "{remove(0)}" << 0 << "QML ListModel (unknown location) remove: index 0 out of range";
- QTest::newRow("remove4b") << "{append({'foo':123});remove(0);remove(0)}" << 0 << "QML ListModel (unknown location) remove: index 0 out of range";
- QTest::newRow("remove4c") << "{append({'foo':123});remove(1)}" << 0 << "QML ListModel (unknown location) remove: index 1 out of range";
-
- QTest::newRow("insert1") << "{insert(0,{'foo':123});count}" << 1 << "";
- QTest::newRow("insert2") << "{insert(1,{'foo':123});count}" << 0 << "QML ListModel (unknown location) insert: index 1 out of range";
- QTest::newRow("insert3a") << "{append({'foo':123});insert(1,{'foo':456});count}" << 2 << "";
- QTest::newRow("insert3b") << "{append({'foo':123});insert(1,{'foo':456});get(0).foo}" << 123 << "";
- QTest::newRow("insert3c") << "{append({'foo':123});insert(1,{'foo':456});get(1).foo}" << 456 << "";
- QTest::newRow("insert3d") << "{append({'foo':123});insert(0,{'foo':456});get(0).foo}" << 456 << "";
- QTest::newRow("insert3e") << "{append({'foo':123});insert(0,{'foo':456});get(1).foo}" << 123 << "";
- QTest::newRow("insert4") << "{append({'foo':123});insert(-1,{'foo':456})}" << 0 << "QML ListModel (unknown location) insert: index -1 out of range";
- QTest::newRow("insert5a") << "{insert(0,123)}" << 0 << "QML ListModel (unknown location) insert: value is not an object";
- QTest::newRow("insert5b") << "{insert(0,[1,2,3])}" << 0 << "QML ListModel (unknown location) insert: value is not an object";
-
- QTest::newRow("set1") << "{append({'foo':123});set(0,{'foo':456});count}" << 1 << "";
- QTest::newRow("set2") << "{append({'foo':123});set(0,{'foo':456});get(0).foo}" << 456 << "";
- QTest::newRow("set3a") << "{append({'foo':123,'bar':456});set(0,{'foo':999});get(0).foo}" << 999 << "";
- QTest::newRow("set3b") << "{append({'foo':123,'bar':456});set(0,{'foo':999});get(0).bar}" << 456 << "";
- QTest::newRow("set4a") << "{set(0,{'foo':456})}" << 0 << "QML ListModel (unknown location) set: index 0 out of range";
- QTest::newRow("set4c") << "{set(-1,{'foo':456})}" << 0 << "QML ListModel (unknown location) set: index -1 out of range";
- QTest::newRow("set5a") << "{append({'foo':123,'bar':456});set(0,123)}" << 0 << "QML ListModel (unknown location) set: value is not an object";
- QTest::newRow("set5b") << "{append({'foo':123,'bar':456});set(0,[1,2,3])}" << 0 << "QML ListModel (unknown location) set: value is not an object";
- QTest::newRow("set6") << "{append({'foo':123});set(1,{'foo':456});count}" << 2 << "";
-
- QTest::newRow("setprop1") << "{append({'foo':123});setProperty(0,'foo',456);count}" << 1 << "";
- QTest::newRow("setprop2") << "{append({'foo':123});setProperty(0,'foo',456);get(0).foo}" << 456 << "";
- QTest::newRow("setprop3a") << "{append({'foo':123,'bar':456});setProperty(0,'foo',999);get(0).foo}" << 999 << "";
- QTest::newRow("setprop3b") << "{append({'foo':123,'bar':456});setProperty(0,'foo',999);get(0).bar}" << 456 << "";
- QTest::newRow("setprop4a") << "{setProperty(0,'foo',456)}" << 0 << "QML ListModel (unknown location) set: index 0 out of range";
- QTest::newRow("setprop4b") << "{setProperty(-1,'foo',456)}" << 0 << "QML ListModel (unknown location) set: index -1 out of range";
- QTest::newRow("setprop4c") << "{append({'foo':123,'bar':456});setProperty(1,'foo',456)}" << 0 << "QML ListModel (unknown location) set: index 1 out of range";
- QTest::newRow("setprop5") << "{append({'foo':123,'bar':456});append({'foo':111});setProperty(1,'bar',222);get(1).bar}" << 222 << "";
-
- QTest::newRow("move1a") << "{append({'foo':123});append({'foo':456});move(0,1,1);count}" << 2 << "";
- QTest::newRow("move1b") << "{append({'foo':123});append({'foo':456});move(0,1,1);get(0).foo}" << 456 << "";
- QTest::newRow("move1c") << "{append({'foo':123});append({'foo':456});move(0,1,1);get(1).foo}" << 123 << "";
- QTest::newRow("move1d") << "{append({'foo':123});append({'foo':456});move(1,0,1);get(0).foo}" << 456 << "";
- QTest::newRow("move1e") << "{append({'foo':123});append({'foo':456});move(1,0,1);get(1).foo}" << 123 << "";
- QTest::newRow("move2a") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(0,1,2);count}" << 3 << "";
- QTest::newRow("move2b") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(0,1,2);get(0).foo}" << 789 << "";
- QTest::newRow("move2c") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(0,1,2);get(1).foo}" << 123 << "";
- QTest::newRow("move2d") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(0,1,2);get(2).foo}" << 456 << "";
- QTest::newRow("move3a") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(1,0,3)}" << 0 << "QML ListModel (unknown location) move: out of range";
- QTest::newRow("move3b") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(1,-1,1)}" << 0 << "QML ListModel (unknown location) move: out of range";
- QTest::newRow("move3c") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(1,0,-1)}" << 0 << "QML ListModel (unknown location) move: out of range";
- QTest::newRow("move3d") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(0,3,1)}" << 0 << "QML ListModel (unknown location) move: out of range";
-
- // Structured model
-
- QTest::newRow("listprop1a") << "{append({'foo':123,'bars':[{'a':1},{'a':2},{'a':3}]});count}" << 1 << "";
- QTest::newRow("listprop1b") << "{append({'foo':123,'bars':[{'a':1},{'a':2},{'a':3}]});get(0).bars.get(1).a}" << 2 << "";
- QTest::newRow("listprop2a") << "{append({'foo':123,'bars':[{'a':1},{'a':2},{'a':3}]});get(0).bars.append({'a':4});get(0).bars.get(3).a}" << 4 << "";
-}
-
-void tst_QmlListModel::dynamic()
-{
- QFETCH(QString, script);
- QFETCH(int, result);
- QFETCH(QString, warning);
-
- QmlEngine engine;
- QmlListModel model;
- QmlEngine::setContextForObject(&model,engine.rootContext());
- engine.rootContext()->addDefaultObject(&model);
- QmlExpression e(engine.rootContext(), script, &model);
- if (!warning.isEmpty())
- QTest::ignoreMessage(QtWarningMsg, warning.toLatin1());
- int actual = e.value().toInt();
- if (e.hasError())
- qDebug() << e.error(); // errors not expected
- QVERIFY(!e.hasError());
- QCOMPARE(actual,result);
-}
-
-void tst_QmlListModel::static_types_data()
-{
- QTest::addColumn<QString>("qml");
- QTest::addColumn<QVariant>("value");
-
- QTest::newRow("string")
- << "ListElement { foo: \"bar\" }"
- << QVariant(QString("bar"));
-
- QTest::newRow("real")
- << "ListElement { foo: 10.5 }"
- << QVariant(10.5);
-
- QTest::newRow("real0")
- << "ListElement { foo: 0 }"
- << QVariant(double(0));
-
- QTest::newRow("bool")
- << "ListElement { foo: false }"
- << QVariant(false);
-
- QTest::newRow("bool")
- << "ListElement { foo: true }"
- << QVariant(true);
-}
-
-void tst_QmlListModel::static_types()
-{
- QFETCH(QString, qml);
- QFETCH(QVariant, value);
-
- qml = "import Qt 4.6\nListModel { " + qml + " }";
-
- QmlEngine engine;
- QmlComponent component(&engine);
- component.setData(qml.toUtf8(),
- QUrl::fromLocalFile(QString("dummy.qml")));
- QVERIFY(!component.isError());
-
- QmlListModel *obj = qobject_cast<QmlListModel*>(component.create());
- QVERIFY(obj != 0);
-
- QScriptValue actual = obj->get(0).property(QLatin1String("foo"));
-
- QCOMPARE(actual.isString(), value.type() == QVariant::String);
- QCOMPARE(actual.isBoolean(), value.type() == QVariant::Bool);
- QCOMPARE(actual.isNumber(), value.type() == QVariant::Double);
-
- QCOMPARE(actual.toString(), value.toString());
-
- delete obj;
-}
-
-void tst_QmlListModel::error_data()
-{
- QTest::addColumn<QString>("qml");
- QTest::addColumn<QString>("error");
-
- QTest::newRow("id not allowed in ListElement")
- << "import Qt 4.6\nListModel { ListElement { id: fred } }"
- << "ListElement: cannot use reserved \"id\" property";
-
- QTest::newRow("id allowed in ListModel")
- << "import Qt 4.6\nListModel { id:model }"
- << "";
-
- QTest::newRow("random properties not allowed in ListModel")
- << "import Qt 4.6\nListModel { foo:123 }"
- << "ListModel: undefined property 'foo'";
-
- QTest::newRow("random properties allowed in ListElement")
- << "import Qt 4.6\nListModel { ListElement { foo:123 } }"
- << "";
-
- QTest::newRow("bindings not allowed in ListElement")
- << "import Qt 4.6\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 Qt 4.6\nListModel { ListElement { foo: [ ListElement { bar: 123 } ] } }"
- << "";
-
- QTest::newRow("default properties not allowed in ListElement")
- << "import Qt 4.6\nListModel { ListElement { Item { } } }"
- << "QTBUG-6082 ListElement should not allow child objects";
-}
-
-void tst_QmlListModel::error()
-{
- QFETCH(QString, qml);
- QFETCH(QString, error);
-
- QmlEngine engine;
- QmlComponent component(&engine);
- component.setData(qml.toUtf8(),
- QUrl::fromLocalFile(QString("dummy.qml")));
- if (error.isEmpty()) {
- QVERIFY(!component.isError());
- } else {
- if (error.startsWith(QLatin1String("QTBUG-")))
- QEXPECT_FAIL("",error.toLatin1(),Abort);
- QVERIFY(component.isError());
- QList<QmlError> errors = component.errors();
- QCOMPARE(errors.count(),1);
- QCOMPARE(errors.at(0).description(),error);
- }
-}
-
-QTEST_MAIN(tst_QmlListModel)
-
-#include "tst_qmllistmodel.moc"
diff --git a/tests/auto/declarative/qmlmetaproperty/qmlmetaproperty.pro b/tests/auto/declarative/qmlmetaproperty/qmlmetaproperty.pro
deleted file mode 100644
index 542c14e..0000000
--- a/tests/auto/declarative/qmlmetaproperty/qmlmetaproperty.pro
+++ /dev/null
@@ -1,5 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qmlmetaproperty.cpp
diff --git a/tests/auto/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp b/tests/auto/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp
deleted file mode 100644
index 050cd3f..0000000
--- a/tests/auto/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp
+++ /dev/null
@@ -1,1136 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtDeclarative/qmlengine.h>
-#include <QtDeclarative/qmlcomponent.h>
-#include <QtDeclarative/qmlmetaproperty.h>
-#include <private/qguard_p.h>
-#include <QtDeclarative/qmlbinding.h>
-#include <QtGui/QLineEdit>
-
-class MyQmlObject : public QObject
-{
- Q_OBJECT
-public:
- MyQmlObject() {}
-};
-
-QML_DECLARE_TYPE(MyQmlObject);
-QML_DEFINE_TYPE(Test,1,0,MyQmlObject,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(QmlListProperty<MyQmlObject> children READ children)
-public:
- MyContainer() {}
-
- QmlListProperty<MyQmlObject> children() { return QmlListProperty<MyQmlObject>(this, m_children); }
-
- static MyAttached *qmlAttachedProperties(QObject *o) {
- return new MyAttached(o);
- }
-
-private:
- QList<MyQmlObject*> m_children;
-};
-
-QML_DECLARE_TYPE(MyContainer);
-QML_DEFINE_TYPE(Test,1,0,MyContainer,MyContainer);
-QML_DECLARE_TYPEINFO(MyContainer, QML_HAS_ATTACHED_PROPERTIES)
-
-class tst_qmlmetaproperty : public QObject
-{
- Q_OBJECT
-public:
- tst_qmlmetaproperty() {}
-
-private slots:
-
- // 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();
-
- // Bugs
- void crashOnValueProperty();
-
-private:
- QmlEngine engine;
-};
-
-void tst_qmlmetaproperty::qmlmetaproperty()
-{
- QmlMetaProperty prop;
-
- QGuard<QmlBinding> binding(new QmlBinding(QString(), 0, 0));
- QVERIFY(binding != 0);
- QGuard<QmlExpression> expression(new QmlExpression());
- QVERIFY(expression != 0);
-
- QObject *obj = new QObject;
-
- QCOMPARE(prop.name(), QString());
- QCOMPARE(prop.read(), QVariant());
- QCOMPARE(prop.write(QVariant()), false);
- QCOMPARE(prop.hasChangedNotifier(), false);
- QCOMPARE(prop.needsChangedNotifier(), false);
- QCOMPARE(prop.connectNotifier(0, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifier(obj, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifier(obj, 0), false);
- QCOMPARE(prop.connectNotifier(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifier(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifier(obj, -1), false);
- QVERIFY(prop.method().signature() == 0);
- QCOMPARE(prop.type(), QmlMetaProperty::Invalid);
- QCOMPARE(prop.isProperty(), false);
- QCOMPARE(prop.isDefault(), false);
- QCOMPARE(prop.isWritable(), false);
- QCOMPARE(prop.isDesignable(), false);
- QCOMPARE(prop.isResettable(), false);
- QCOMPARE(prop.isValid(), false);
- QCOMPARE(prop.object(), (QObject *)0);
- QCOMPARE(prop.propertyCategory(), QmlMetaProperty::InvalidProperty);
- QCOMPARE(prop.propertyType(), 0);
- QCOMPARE(prop.propertyTypeName(), (const char *)0);
- QVERIFY(prop.property().name() == 0);
- QVERIFY(prop.binding() == 0);
- QVERIFY(prop.setBinding(binding) == 0);
- QVERIFY(binding == 0);
- QVERIFY(prop.signalExpression() == 0);
- QVERIFY(prop.setSignalExpression(expression) == 0);
- QVERIFY(expression == 0);
- QCOMPARE(prop.coreIndex(), -1);
- QCOMPARE(prop.valueTypeCoreIndex(), -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(int resettableProperty READ resettableProperty WRITE setResettableProperty RESET resetProperty);
-
- 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; }
-
- int resettableProperty() const { return m_resetProperty; }
- void setResettableProperty(int r) { m_resetProperty = r; }
- void resetProperty() { m_resetProperty = 9; }
-
-signals:
- void clicked();
-
-private:
- int m_resetProperty;
- QRect m_rect;
- QUrl m_url;
-};
-
-QML_DECLARE_TYPE(PropertyObject);
-QML_DEFINE_TYPE(Test,1,0,PropertyObject,PropertyObject);
-
-void tst_qmlmetaproperty::qmlmetaproperty_object()
-{
- QObject object; // Has no default property
- PropertyObject dobject; // Has default property
-
- {
- QmlMetaProperty prop(&object);
-
- QGuard<QmlBinding> binding(new QmlBinding(QString(), 0, 0));
- QVERIFY(binding != 0);
- QGuard<QmlExpression> expression(new QmlExpression());
- QVERIFY(expression != 0);
-
- QObject *obj = new QObject;
-
- QCOMPARE(prop.name(), QString());
- QCOMPARE(prop.read(), QVariant());
- QCOMPARE(prop.write(QVariant()), false);
- QCOMPARE(prop.hasChangedNotifier(), false);
- QCOMPARE(prop.needsChangedNotifier(), false);
- QCOMPARE(prop.connectNotifier(0, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifier(obj, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifier(obj, 0), false);
- QCOMPARE(prop.connectNotifier(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifier(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifier(obj, -1), false);
- QVERIFY(prop.method().signature() == 0);
- QCOMPARE(prop.type(), QmlMetaProperty::Invalid);
- QCOMPARE(prop.isProperty(), false);
- QCOMPARE(prop.isDefault(), false);
- QCOMPARE(prop.isWritable(), false);
- QCOMPARE(prop.isDesignable(), false);
- QCOMPARE(prop.isResettable(), false);
- QCOMPARE(prop.isValid(), false);
- QCOMPARE(prop.object(), (QObject *)0);
- QCOMPARE(prop.propertyCategory(), QmlMetaProperty::InvalidProperty);
- QCOMPARE(prop.propertyType(), 0);
- QCOMPARE(prop.propertyTypeName(), (const char *)0);
- QVERIFY(prop.property().name() == 0);
- QVERIFY(prop.binding() == 0);
- QVERIFY(prop.setBinding(binding) == 0);
- QVERIFY(binding == 0);
- QVERIFY(prop.signalExpression() == 0);
- QVERIFY(prop.setSignalExpression(expression) == 0);
- QVERIFY(expression == 0);
- QCOMPARE(prop.coreIndex(), -1);
- QCOMPARE(prop.valueTypeCoreIndex(), -1);
-
- delete obj;
- }
-
- {
- QmlMetaProperty prop(&dobject);
-
- QGuard<QmlBinding> binding(new QmlBinding(QString(), 0, 0));
- binding->setTarget(prop);
- QVERIFY(binding != 0);
- QGuard<QmlExpression> expression(new QmlExpression());
- QVERIFY(expression != 0);
-
- QObject *obj = new QObject;
-
- QCOMPARE(prop.name(), QString("defaultProperty"));
- QCOMPARE(prop.read(), QVariant(10));
- QCOMPARE(prop.write(QVariant()), false);
- QCOMPARE(prop.hasChangedNotifier(), false);
- QCOMPARE(prop.needsChangedNotifier(), true);
- QCOMPARE(prop.connectNotifier(0, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifier(obj, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifier(obj, 0), false);
- QCOMPARE(prop.connectNotifier(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifier(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifier(obj, -1), false);
- QVERIFY(prop.method().signature() == 0);
- QCOMPARE(prop.type(), (QmlMetaProperty::Type)(QmlMetaProperty::Property | QmlMetaProperty::Default));
- QCOMPARE(prop.isProperty(), true);
- QCOMPARE(prop.isDefault(), true);
- QCOMPARE(prop.isWritable(), false);
- QCOMPARE(prop.isDesignable(), true);
- QCOMPARE(prop.isResettable(), false);
- QCOMPARE(prop.isValid(), true);
- QCOMPARE(prop.object(), &dobject);
- QCOMPARE(prop.propertyCategory(), QmlMetaProperty::Normal);
- QCOMPARE(prop.propertyType(), (int)QVariant::Int);
- QCOMPARE(prop.propertyTypeName(), "int");
- QCOMPARE(QString(prop.property().name()), QString("defaultProperty"));
- QVERIFY(prop.binding() == 0);
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>:-1: Unable to assign null to int");
- QVERIFY(prop.setBinding(binding) == 0);
- QVERIFY(binding != 0);
- QVERIFY(prop.binding() == binding);
- QVERIFY(prop.signalExpression() == 0);
- QVERIFY(prop.setSignalExpression(expression) == 0);
- QVERIFY(expression == 0);
- QCOMPARE(prop.coreIndex(), dobject.metaObject()->indexOfProperty("defaultProperty"));
- QCOMPARE(prop.valueTypeCoreIndex(), -1);
-
- delete obj;
- }
-}
-
-void tst_qmlmetaproperty::qmlmetaproperty_object_string()
-{
- QObject object;
- PropertyObject dobject;
-
- {
- QmlMetaProperty prop(&object, QString("defaultProperty"));
-
- QGuard<QmlBinding> binding(new QmlBinding(QString(), 0, 0));
- QVERIFY(binding != 0);
- QGuard<QmlExpression> expression(new QmlExpression());
- QVERIFY(expression != 0);
-
- QObject *obj = new QObject;
-
- QCOMPARE(prop.name(), QString());
- QCOMPARE(prop.read(), QVariant());
- QCOMPARE(prop.write(QVariant()), false);
- QCOMPARE(prop.hasChangedNotifier(), false);
- QCOMPARE(prop.needsChangedNotifier(), false);
- QCOMPARE(prop.connectNotifier(0, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifier(obj, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifier(obj, 0), false);
- QCOMPARE(prop.connectNotifier(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifier(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifier(obj, -1), false);
- QVERIFY(prop.method().signature() == 0);
- QCOMPARE(prop.type(), QmlMetaProperty::Invalid);
- QCOMPARE(prop.isProperty(), false);
- QCOMPARE(prop.isDefault(), false);
- QCOMPARE(prop.isWritable(), false);
- QCOMPARE(prop.isDesignable(), false);
- QCOMPARE(prop.isResettable(), false);
- QCOMPARE(prop.isValid(), false);
- QCOMPARE(prop.object(), (QObject *)0);
- QCOMPARE(prop.propertyCategory(), QmlMetaProperty::InvalidProperty);
- QCOMPARE(prop.propertyType(), 0);
- QCOMPARE(prop.propertyTypeName(), (const char *)0);
- QVERIFY(prop.property().name() == 0);
- QVERIFY(prop.binding() == 0);
- QVERIFY(prop.setBinding(binding) == 0);
- QVERIFY(binding == 0);
- QVERIFY(prop.signalExpression() == 0);
- QVERIFY(prop.setSignalExpression(expression) == 0);
- QVERIFY(expression == 0);
- QCOMPARE(prop.coreIndex(), -1);
- QCOMPARE(prop.valueTypeCoreIndex(), -1);
-
- delete obj;
- }
-
- {
- QmlMetaProperty prop(&dobject, QString("defaultProperty"));
-
- QGuard<QmlBinding> binding(new QmlBinding(QString(), 0, 0));
- binding->setTarget(prop);
- QVERIFY(binding != 0);
- QGuard<QmlExpression> expression(new QmlExpression());
- QVERIFY(expression != 0);
-
- QObject *obj = new QObject;
-
- QCOMPARE(prop.name(), QString("defaultProperty"));
- QCOMPARE(prop.read(), QVariant(10));
- QCOMPARE(prop.write(QVariant()), false);
- QCOMPARE(prop.hasChangedNotifier(), false);
- QCOMPARE(prop.needsChangedNotifier(), true);
- QCOMPARE(prop.connectNotifier(0, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifier(obj, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifier(obj, 0), false);
- QCOMPARE(prop.connectNotifier(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifier(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifier(obj, -1), false);
- QVERIFY(prop.method().signature() == 0);
- QCOMPARE(prop.type(), QmlMetaProperty::Property);
- QCOMPARE(prop.isProperty(), true);
- QCOMPARE(prop.isDefault(), false);
- QCOMPARE(prop.isWritable(), false);
- QCOMPARE(prop.isDesignable(), true);
- QCOMPARE(prop.isResettable(), false);
- QCOMPARE(prop.isValid(), true);
- QCOMPARE(prop.object(), &dobject);
- QCOMPARE(prop.propertyCategory(), QmlMetaProperty::Normal);
- QCOMPARE(prop.propertyType(), (int)QVariant::Int);
- QCOMPARE(prop.propertyTypeName(), "int");
- QCOMPARE(QString(prop.property().name()), QString("defaultProperty"));
- QVERIFY(prop.binding() == 0);
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>:-1: Unable to assign null to int");
- QVERIFY(prop.setBinding(binding) == 0);
- QVERIFY(binding != 0);
- QVERIFY(prop.binding() == binding);
- QVERIFY(prop.signalExpression() == 0);
- QVERIFY(prop.setSignalExpression(expression) == 0);
- QVERIFY(expression == 0);
- QCOMPARE(prop.coreIndex(), dobject.metaObject()->indexOfProperty("defaultProperty"));
- QCOMPARE(prop.valueTypeCoreIndex(), -1);
-
- delete obj;
- }
-
- {
- QmlMetaProperty prop(&dobject, QString("onClicked"));
-
- QGuard<QmlBinding> binding(new QmlBinding(QString(), 0, 0));
- binding->setTarget(prop);
- QVERIFY(binding != 0);
- QGuard<QmlExpression> expression(new QmlExpression());
- QVERIFY(expression != 0);
-
- QObject *obj = new QObject;
-
- QCOMPARE(prop.name(), QString("onClicked"));
- QCOMPARE(prop.read(), QVariant());
- QCOMPARE(prop.write(QVariant("Hello")), false);
- QCOMPARE(prop.hasChangedNotifier(), false);
- QCOMPARE(prop.needsChangedNotifier(), false);
- QCOMPARE(prop.connectNotifier(0, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifier(obj, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifier(obj, 0), false);
- QCOMPARE(prop.connectNotifier(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifier(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifier(obj, -1), false);
- QCOMPARE(QString(prop.method().signature()), QString("clicked()"));
- QCOMPARE(prop.type(), QmlMetaProperty::SignalProperty);
- QCOMPARE(prop.isProperty(), false);
- QCOMPARE(prop.isDefault(), false);
- QCOMPARE(prop.isWritable(), false);
- QCOMPARE(prop.isDesignable(), false);
- QCOMPARE(prop.isResettable(), false);
- QCOMPARE(prop.isValid(), true);
- QCOMPARE(prop.object(), &dobject);
- QCOMPARE(prop.propertyCategory(), QmlMetaProperty::InvalidProperty);
- QCOMPARE(prop.propertyType(), 0);
- QCOMPARE(prop.propertyTypeName(), (const char *)0);
- QCOMPARE(prop.property().name(), (const char *)0);
- QVERIFY(prop.binding() == 0);
- QVERIFY(prop.setBinding(binding) == 0);
- QVERIFY(binding == 0);
- QVERIFY(prop.signalExpression() == 0);
- QVERIFY(prop.setSignalExpression(expression) == 0);
- QVERIFY(expression != 0);
- QVERIFY(prop.signalExpression() == expression);
- QCOMPARE(prop.coreIndex(), dobject.metaObject()->indexOfMethod("clicked()"));
- QCOMPARE(prop.valueTypeCoreIndex(), -1);
-
- delete obj;
- }
-}
-
-void tst_qmlmetaproperty::qmlmetaproperty_object_context()
-{
- QObject object; // Has no default property
- PropertyObject dobject; // Has default property
-
- {
- QmlMetaProperty prop(&object, engine.rootContext());
-
- QGuard<QmlBinding> binding(new QmlBinding(QString(), 0, 0));
- QVERIFY(binding != 0);
- QGuard<QmlExpression> expression(new QmlExpression());
- QVERIFY(expression != 0);
-
- QObject *obj = new QObject;
-
- QCOMPARE(prop.name(), QString());
- QCOMPARE(prop.read(), QVariant());
- QCOMPARE(prop.write(QVariant()), false);
- QCOMPARE(prop.hasChangedNotifier(), false);
- QCOMPARE(prop.needsChangedNotifier(), false);
- QCOMPARE(prop.connectNotifier(0, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifier(obj, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifier(obj, 0), false);
- QCOMPARE(prop.connectNotifier(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifier(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifier(obj, -1), false);
- QVERIFY(prop.method().signature() == 0);
- QCOMPARE(prop.type(), QmlMetaProperty::Invalid);
- QCOMPARE(prop.isProperty(), false);
- QCOMPARE(prop.isDefault(), false);
- QCOMPARE(prop.isWritable(), false);
- QCOMPARE(prop.isDesignable(), false);
- QCOMPARE(prop.isResettable(), false);
- QCOMPARE(prop.isValid(), false);
- QCOMPARE(prop.object(), (QObject *)0);
- QCOMPARE(prop.propertyCategory(), QmlMetaProperty::InvalidProperty);
- QCOMPARE(prop.propertyType(), 0);
- QCOMPARE(prop.propertyTypeName(), (const char *)0);
- QVERIFY(prop.property().name() == 0);
- QVERIFY(prop.binding() == 0);
- QVERIFY(prop.setBinding(binding) == 0);
- QVERIFY(binding == 0);
- QVERIFY(prop.signalExpression() == 0);
- QVERIFY(prop.setSignalExpression(expression) == 0);
- QVERIFY(expression == 0);
- QCOMPARE(prop.coreIndex(), -1);
- QCOMPARE(prop.valueTypeCoreIndex(), -1);
-
- delete obj;
- }
-
- {
- QmlMetaProperty prop(&dobject, engine.rootContext());
-
- QGuard<QmlBinding> binding(new QmlBinding(QString(), 0, 0));
- binding->setTarget(prop);
- QVERIFY(binding != 0);
- QGuard<QmlExpression> expression(new QmlExpression());
- QVERIFY(expression != 0);
-
- QObject *obj = new QObject;
-
- QCOMPARE(prop.name(), QString("defaultProperty"));
- QCOMPARE(prop.read(), QVariant(10));
- QCOMPARE(prop.write(QVariant()), false);
- QCOMPARE(prop.hasChangedNotifier(), false);
- QCOMPARE(prop.needsChangedNotifier(), true);
- QCOMPARE(prop.connectNotifier(0, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifier(obj, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifier(obj, 0), false);
- QCOMPARE(prop.connectNotifier(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifier(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifier(obj, -1), false);
- QVERIFY(prop.method().signature() == 0);
- QCOMPARE(prop.type(), (QmlMetaProperty::Type)(QmlMetaProperty::Property | QmlMetaProperty::Default));
- QCOMPARE(prop.isProperty(), true);
- QCOMPARE(prop.isDefault(), true);
- QCOMPARE(prop.isWritable(), false);
- QCOMPARE(prop.isDesignable(), true);
- QCOMPARE(prop.isResettable(), false);
- QCOMPARE(prop.isValid(), true);
- QCOMPARE(prop.object(), &dobject);
- QCOMPARE(prop.propertyCategory(), QmlMetaProperty::Normal);
- QCOMPARE(prop.propertyType(), (int)QVariant::Int);
- QCOMPARE(prop.propertyTypeName(), "int");
- QCOMPARE(QString(prop.property().name()), QString("defaultProperty"));
- QVERIFY(prop.binding() == 0);
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>:-1: Unable to assign null to int");
- QVERIFY(prop.setBinding(binding) == 0);
- QVERIFY(binding != 0);
- QVERIFY(prop.binding() == binding);
- QVERIFY(prop.signalExpression() == 0);
- QVERIFY(prop.setSignalExpression(expression) == 0);
- QVERIFY(expression == 0);
- QCOMPARE(prop.coreIndex(), dobject.metaObject()->indexOfProperty("defaultProperty"));
- QCOMPARE(prop.valueTypeCoreIndex(), -1);
-
- delete obj;
- }
-}
-
-void tst_qmlmetaproperty::qmlmetaproperty_object_string_context()
-{
- QObject object;
- PropertyObject dobject;
-
- {
- QmlMetaProperty prop(&object, QString("defaultProperty"), engine.rootContext());
-
- QGuard<QmlBinding> binding(new QmlBinding(QString(), 0, 0));
- QVERIFY(binding != 0);
- QGuard<QmlExpression> expression(new QmlExpression());
- QVERIFY(expression != 0);
-
- QObject *obj = new QObject;
-
- QCOMPARE(prop.name(), QString());
- QCOMPARE(prop.read(), QVariant());
- QCOMPARE(prop.write(QVariant()), false);
- QCOMPARE(prop.hasChangedNotifier(), false);
- QCOMPARE(prop.needsChangedNotifier(), false);
- QCOMPARE(prop.connectNotifier(0, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifier(obj, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifier(obj, 0), false);
- QCOMPARE(prop.connectNotifier(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifier(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifier(obj, -1), false);
- QVERIFY(prop.method().signature() == 0);
- QCOMPARE(prop.type(), QmlMetaProperty::Invalid);
- QCOMPARE(prop.isProperty(), false);
- QCOMPARE(prop.isDefault(), false);
- QCOMPARE(prop.isWritable(), false);
- QCOMPARE(prop.isDesignable(), false);
- QCOMPARE(prop.isResettable(), false);
- QCOMPARE(prop.isValid(), false);
- QCOMPARE(prop.object(), (QObject *)0);
- QCOMPARE(prop.propertyCategory(), QmlMetaProperty::InvalidProperty);
- QCOMPARE(prop.propertyType(), 0);
- QCOMPARE(prop.propertyTypeName(), (const char *)0);
- QVERIFY(prop.property().name() == 0);
- QVERIFY(prop.binding() == 0);
- QVERIFY(prop.setBinding(binding) == 0);
- QVERIFY(binding == 0);
- QVERIFY(prop.signalExpression() == 0);
- QVERIFY(prop.setSignalExpression(expression) == 0);
- QVERIFY(expression == 0);
- QCOMPARE(prop.coreIndex(), -1);
- QCOMPARE(prop.valueTypeCoreIndex(), -1);
-
- delete obj;
- }
-
- {
- QmlMetaProperty prop(&dobject, QString("defaultProperty"), engine.rootContext());
-
- QGuard<QmlBinding> binding(new QmlBinding(QString(), 0, 0));
- binding->setTarget(prop);
- QVERIFY(binding != 0);
- QGuard<QmlExpression> expression(new QmlExpression());
- QVERIFY(expression != 0);
-
- QObject *obj = new QObject;
-
- QCOMPARE(prop.name(), QString("defaultProperty"));
- QCOMPARE(prop.read(), QVariant(10));
- QCOMPARE(prop.write(QVariant()), false);
- QCOMPARE(prop.hasChangedNotifier(), false);
- QCOMPARE(prop.needsChangedNotifier(), true);
- QCOMPARE(prop.connectNotifier(0, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifier(obj, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifier(obj, 0), false);
- QCOMPARE(prop.connectNotifier(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifier(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifier(obj, -1), false);
- QVERIFY(prop.method().signature() == 0);
- QCOMPARE(prop.type(), QmlMetaProperty::Property);
- QCOMPARE(prop.isProperty(), true);
- QCOMPARE(prop.isDefault(), false);
- QCOMPARE(prop.isWritable(), false);
- QCOMPARE(prop.isDesignable(), true);
- QCOMPARE(prop.isResettable(), false);
- QCOMPARE(prop.isValid(), true);
- QCOMPARE(prop.object(), &dobject);
- QCOMPARE(prop.propertyCategory(), QmlMetaProperty::Normal);
- QCOMPARE(prop.propertyType(), (int)QVariant::Int);
- QCOMPARE(prop.propertyTypeName(), "int");
- QCOMPARE(QString(prop.property().name()), QString("defaultProperty"));
- QVERIFY(prop.binding() == 0);
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>:-1: Unable to assign null to int");
- QVERIFY(prop.setBinding(binding) == 0);
- QVERIFY(binding != 0);
- QVERIFY(prop.binding() == binding);
- QVERIFY(prop.signalExpression() == 0);
- QVERIFY(prop.setSignalExpression(expression) == 0);
- QVERIFY(expression == 0);
- QCOMPARE(prop.coreIndex(), dobject.metaObject()->indexOfProperty("defaultProperty"));
- QCOMPARE(prop.valueTypeCoreIndex(), -1);
-
- delete obj;
- }
-
- {
- QmlMetaProperty prop(&dobject, QString("onClicked"), engine.rootContext());
-
- QGuard<QmlBinding> binding(new QmlBinding(QString(), 0, 0));
- binding->setTarget(prop);
- QVERIFY(binding != 0);
- QGuard<QmlExpression> expression(new QmlExpression());
- QVERIFY(expression != 0);
-
- QObject *obj = new QObject;
-
- QCOMPARE(prop.name(), QString("onClicked"));
- QCOMPARE(prop.read(), QVariant());
- QCOMPARE(prop.write(QVariant("Hello")), false);
- QCOMPARE(prop.hasChangedNotifier(), false);
- QCOMPARE(prop.needsChangedNotifier(), false);
- QCOMPARE(prop.connectNotifier(0, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifier(obj, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifier(obj, 0), false);
- QCOMPARE(prop.connectNotifier(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifier(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifier(obj, -1), false);
- QCOMPARE(QString(prop.method().signature()), QString("clicked()"));
- QCOMPARE(prop.type(), QmlMetaProperty::SignalProperty);
- QCOMPARE(prop.isProperty(), false);
- QCOMPARE(prop.isDefault(), false);
- QCOMPARE(prop.isWritable(), false);
- QCOMPARE(prop.isDesignable(), false);
- QCOMPARE(prop.isResettable(), false);
- QCOMPARE(prop.isValid(), true);
- QCOMPARE(prop.object(), &dobject);
- QCOMPARE(prop.propertyCategory(), QmlMetaProperty::InvalidProperty);
- QCOMPARE(prop.propertyType(), 0);
- QCOMPARE(prop.propertyTypeName(), (const char *)0);
- QCOMPARE(prop.property().name(), (const char *)0);
- QVERIFY(prop.binding() == 0);
- QVERIFY(prop.setBinding(binding) == 0);
- QVERIFY(binding == 0);
- QVERIFY(prop.signalExpression() == 0);
- QVERIFY(prop.setSignalExpression(expression) == 0);
- QVERIFY(expression != 0);
- QVERIFY(prop.signalExpression() == expression);
- QCOMPARE(prop.coreIndex(), dobject.metaObject()->indexOfMethod("clicked()"));
- QCOMPARE(prop.valueTypeCoreIndex(), -1);
-
- delete obj;
- }
-}
-
-void tst_qmlmetaproperty::name()
-{
- {
- QmlMetaProperty p;
- QCOMPARE(p.name(), QString());
- }
-
- {
- PropertyObject o;
- QmlMetaProperty p(&o);
- QCOMPARE(p.name(), QString("defaultProperty"));
- }
-
- {
- QObject o;
- QmlMetaProperty p(&o, QString("objectName"));
- QCOMPARE(p.name(), QString("objectName"));
- }
-
- {
- PropertyObject o;
- QmlMetaProperty p(&o, "onClicked");
- QCOMPARE(p.name(), QString("onClicked"));
- }
-
- {
- QObject o;
- QmlMetaProperty p(&o, "onClicked");
- QCOMPARE(p.name(), QString());
- }
-
- {
- QObject o;
- QmlMetaProperty p(&o, "foo");
- QCOMPARE(p.name(), QString());
- }
-
- {
- QmlMetaProperty p(0, "foo");
- QCOMPARE(p.name(), QString());
- }
-
- {
- PropertyObject o;
- QmlMetaProperty p = QmlMetaProperty::createProperty(&o, "rectProperty");
- QCOMPARE(p.name(), QString("rectProperty"));
- }
-
- {
- PropertyObject o;
- QmlMetaProperty p = QmlMetaProperty::createProperty(&o, "rectProperty.x");
- QCOMPARE(p.name(), QString("rectProperty.x"));
- }
-
- {
- PropertyObject o;
- QmlMetaProperty p = QmlMetaProperty::createProperty(&o, "rectProperty.foo");
- QCOMPARE(p.name(), QString());
- }
-}
-
-void tst_qmlmetaproperty::read()
-{
- // Invalid
- {
- QmlMetaProperty p;
- QCOMPARE(p.read(), QVariant());
- }
-
- // Default prop
- {
- PropertyObject o;
- QmlMetaProperty p(&o);
- QCOMPARE(p.read(), QVariant(10));
- }
-
- // Invalid default prop
- {
- QObject o;
- QmlMetaProperty p(&o);
- QCOMPARE(p.read(), QVariant());
- }
-
- // Value prop by name
- {
- QObject o;
-
- QmlMetaProperty p(&o, "objectName");
- QCOMPARE(p.read(), QVariant(QString()));
-
- o.setObjectName("myName");
-
- QCOMPARE(p.read(), QVariant("myName"));
- }
-
- // Value-type prop
- {
- PropertyObject o;
- QmlMetaProperty p = QmlMetaProperty::createProperty(&o, "rectProperty.x");
- QCOMPARE(p.read(), QVariant(10));
- }
-
- // Invalid value-type prop
- {
- PropertyObject o;
- QmlMetaProperty p = QmlMetaProperty::createProperty(&o, "rectProperty.foo");
- QCOMPARE(p.read(), QVariant());
- }
-
- // Signal property
- {
- PropertyObject o;
- QmlMetaProperty p(&o, "onClicked");
- QCOMPARE(p.read(), QVariant());
-
- QVERIFY(0 == p.setSignalExpression(new QmlExpression()));
- QVERIFY(0 != p.signalExpression());
-
- QCOMPARE(p.read(), QVariant());
- }
-
- // Deleted object
- {
- PropertyObject *o = new PropertyObject;
- QmlMetaProperty p = QmlMetaProperty::createProperty(o, "rectProperty.x");
- QCOMPARE(p.read(), QVariant(10));
- delete o;
- QCOMPARE(p.read(), QVariant());
- }
-
- // Attached property
- {
- QmlComponent component(&engine);
- component.setData("import Test 1.0\nMyContainer { }", QUrl());
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QmlMetaProperty p = QmlMetaProperty::createProperty(object, "MyContainer.foo", qmlContext(object));
- QCOMPARE(p.read(), QVariant(13));
- delete object;
- }
- {
- QmlComponent component(&engine);
- component.setData("import Test 1.0\nMyContainer { MyContainer.foo: 10 }", QUrl());
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QmlMetaProperty p = QmlMetaProperty::createProperty(object, "MyContainer.foo", qmlContext(object));
- QCOMPARE(p.read(), QVariant(10));
- delete object;
- }
- {
- QmlComponent component(&engine);
- component.setData("import Test 1.0 as Foo\nFoo.MyContainer { Foo.MyContainer.foo: 10 }", QUrl());
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QmlMetaProperty p = QmlMetaProperty::createProperty(object, "Foo.MyContainer.foo", qmlContext(object));
- QCOMPARE(p.read(), QVariant(10));
- delete object;
- }
-}
-
-void tst_qmlmetaproperty::write()
-{
- // Invalid
- {
- QmlMetaProperty p;
- QCOMPARE(p.write(QVariant(10)), false);
- }
-
- // Read-only default prop
- {
- PropertyObject o;
- QmlMetaProperty p(&o);
- QCOMPARE(p.write(QVariant(10)), false);
- }
-
- // Invalid default prop
- {
- QObject o;
- QmlMetaProperty p(&o);
- QCOMPARE(p.write(QVariant(10)), false);
- }
-
- // Read-only prop by name
- {
- PropertyObject o;
- QmlMetaProperty p(&o, QString("defaultProperty"));
- QCOMPARE(p.write(QVariant(10)), false);
- }
-
- // Writable prop by name
- {
- PropertyObject o;
- QmlMetaProperty p(&o, QString("objectName"));
- QCOMPARE(o.objectName(), QString());
- QCOMPARE(p.write(QVariant(QString("myName"))), true);
- QCOMPARE(o.objectName(), QString("myName"));
- }
-
- // Deleted object
- {
- PropertyObject *o = new PropertyObject;
- QmlMetaProperty 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;
- QmlMetaProperty p(&o, "onClicked");
- QCOMPARE(p.write(QVariant("console.log(1921)")), false);
-
- QVERIFY(0 == p.setSignalExpression(new QmlExpression()));
- QVERIFY(0 != p.signalExpression());
-
- QCOMPARE(p.write(QVariant("console.log(1921)")), false);
-
- QVERIFY(0 != p.signalExpression());
- }
-
- // Value-type property
- {
- PropertyObject o;
- QmlMetaProperty p(&o, "wrectProperty");
-
- QCOMPARE(o.wrectProperty(), QRect());
- QCOMPARE(p.write(QRect(1, 13, 99, 8)), true);
- QCOMPARE(o.wrectProperty(), QRect(1, 13, 99, 8));
-
- QmlMetaProperty p2 = QmlMetaProperty::createProperty(&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;
- QmlMetaProperty p(&o, "url");
-
- QCOMPARE(p.write(QUrl("main.qml")), true);
- QCOMPARE(o.url(), QUrl("main.qml"));
-
- QmlMetaProperty 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);
- }
-
- // Attached property
- {
- QmlComponent component(&engine);
- component.setData("import Test 1.0\nMyContainer { }", QUrl());
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QmlMetaProperty p = QmlMetaProperty::createProperty(object, "MyContainer.foo", qmlContext(object));
- p.write(QVariant(99));
- QCOMPARE(p.read(), QVariant(99));
- delete object;
- }
- {
- QmlComponent component(&engine);
- component.setData("import Test 1.0 as Foo\nFoo.MyContainer { Foo.MyContainer.foo: 10 }", QUrl());
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QmlMetaProperty p = QmlMetaProperty::createProperty(object, "Foo.MyContainer.foo", qmlContext(object));
- p.write(QVariant(99));
- QCOMPARE(p.read(), QVariant(99));
- delete object;
- }
-}
-
-void tst_qmlmetaproperty::reset()
-{
- // Invalid
- {
- QmlMetaProperty p;
- QCOMPARE(p.isResettable(), false);
- QCOMPARE(p.reset(), false);
- }
-
- // Read-only default prop
- {
- PropertyObject o;
- QmlMetaProperty p(&o);
- QCOMPARE(p.isResettable(), false);
- QCOMPARE(p.reset(), false);
- }
-
- // Invalid default prop
- {
- QObject o;
- QmlMetaProperty p(&o);
- QCOMPARE(p.isResettable(), false);
- QCOMPARE(p.reset(), false);
- }
-
- // Non-resettable-only prop by name
- {
- PropertyObject o;
- QmlMetaProperty p(&o, QString("defaultProperty"));
- QCOMPARE(p.isResettable(), false);
- QCOMPARE(p.reset(), false);
- }
-
- // Resettable prop by name
- {
- PropertyObject o;
- QmlMetaProperty 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;
-
- QmlMetaProperty 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;
- QmlMetaProperty p(&o, "onClicked");
-
- QCOMPARE(p.isResettable(), false);
- QCOMPARE(p.reset(), false);
- }
-}
-
-void tst_qmlmetaproperty::writeObjectToList()
-{
- QmlComponent containerComponent(&engine);
- containerComponent.setData("import Test 1.0\nMyContainer { children: MyQmlObject {} }", QUrl());
- MyContainer *container = qobject_cast<MyContainer*>(containerComponent.create());
- QVERIFY(container != 0);
- QmlListReference list(container, "children");
- QVERIFY(list.count() == 1);
-
- MyQmlObject *object = new MyQmlObject;
- QmlMetaProperty prop(container, "children");
- prop.write(qVariantFromValue(object));
- QCOMPARE(list.count(), 1);
- QCOMPARE(list.at(0), object);
-}
-
-Q_DECLARE_METATYPE(QList<QObject *>);
-void tst_qmlmetaproperty::writeListToList()
-{
- QmlComponent containerComponent(&engine);
- containerComponent.setData("import Test 1.0\nMyContainer { children: MyQmlObject {} }", QUrl());
- MyContainer *container = qobject_cast<MyContainer*>(containerComponent.create());
- QVERIFY(container != 0);
- QmlListReference list(container, "children");
- QVERIFY(list.count() == 1);
-
- QList<QObject*> objList;
- objList << new MyQmlObject() << new MyQmlObject() << new MyQmlObject() << new MyQmlObject();
- QmlMetaProperty 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_qmlmetaproperty::crashOnValueProperty()
-{
- QmlEngine *engine = new QmlEngine;
- QmlComponent component(engine);
-
- component.setData("import Test 1.0\nPropertyObject { wrectProperty.x: 10 }", QUrl());
- PropertyObject *obj = qobject_cast<PropertyObject*>(component.create());
- QVERIFY(obj != 0);
-
- QmlMetaProperty p = QmlMetaProperty::createProperty(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));
-}
-
-QTEST_MAIN(tst_qmlmetaproperty)
-
-#include "tst_qmlmetaproperty.moc"
diff --git a/tests/auto/declarative/qmlmetatype/qmlmetatype.pro b/tests/auto/declarative/qmlmetatype/qmlmetatype.pro
deleted file mode 100644
index 3a9a400..0000000
--- a/tests/auto/declarative/qmlmetatype/qmlmetatype.pro
+++ /dev/null
@@ -1,6 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative
-SOURCES += tst_qmlmetatype.cpp
-macx:CONFIG -= app_bundle
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmlmetatype/tst_qmlmetatype.cpp b/tests/auto/declarative/qmlmetatype/tst_qmlmetatype.cpp
deleted file mode 100644
index 750ccf8..0000000
--- a/tests/auto/declarative/qmlmetatype/tst_qmlmetatype.cpp
+++ /dev/null
@@ -1,371 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qtest.h>
-#include <QmlMetaType>
-#include <QLocale>
-#include <QPixmap>
-#include <QBitmap>
-#include <QPen>
-#include <QTextLength>
-#include <QMatrix4x4>
-#include <QVector2D>
-#include <QVector3D>
-#include <QVector4D>
-#include <QQuaternion>
-#include <qml.h>
-
-class tst_qmlmetatype : public QObject
-{
- Q_OBJECT
-public:
- tst_qmlmetatype() {}
-
-private slots:
- void copy();
-
- 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);
-QML_DEFINE_TYPE(Test, 1, 0, TestType, TestType);
-
-class ParserStatusTestType : public QObject, public QmlParserStatus
-{
- Q_OBJECT
- Q_CLASSINFO("DefaultProperty", "foo"); // Missing default property
-};
-QML_DECLARE_TYPE(ParserStatusTestType);
-QML_DEFINE_TYPE(Test, 1, 0, ParserStatusTestType, ParserStatusTestType);
-
-class ValueSourceTestType : public QObject, public QmlPropertyValueSource
-{
- Q_OBJECT
- Q_INTERFACES(QmlPropertyValueSource)
-public:
- virtual void setTarget(const QmlMetaProperty &) {}
-};
-QML_DECLARE_TYPE(ValueSourceTestType);
-QML_DEFINE_TYPE(Test, 1, 0, ValueSourceTestType, ValueSourceTestType);
-
-class ValueInterceptorTestType : public QObject, public QmlPropertyValueInterceptor
-{
- Q_OBJECT
- Q_INTERFACES(QmlPropertyValueInterceptor)
-public:
- virtual void setTarget(const QmlMetaProperty &) {}
- virtual void write(const QVariant &) {}
-};
-QML_DECLARE_TYPE(ValueInterceptorTestType);
-QML_DEFINE_TYPE(Test, 1, 0, ValueInterceptorTestType, ValueInterceptorTestType);
-
-
-#define COPY_TEST(cpptype, metatype, value, defaultvalue) \
-{ \
- cpptype v = (value); cpptype v2 = (value); \
- QVERIFY(QmlMetaType::copy(QMetaType:: metatype, &v, 0)); \
- QVERIFY(v == (defaultvalue)); \
- QVERIFY(QmlMetaType::copy(QMetaType:: metatype, &v, &v2)); \
- QVERIFY(v == (value)); \
-}
-
-#define QT_COPY_TEST(type, value) \
-{ \
- type v = (value); type v2 = (value); \
- QVERIFY(QmlMetaType::copy(QMetaType:: type, &v, 0)); \
- QVERIFY(v == (type ())); \
- QVERIFY(QmlMetaType::copy(QMetaType:: type, &v, &v2)); \
- QVERIFY(v == (value)); \
-}
-
-void tst_qmlmetatype::copy()
-{
- QVERIFY(QmlMetaType::copy(QMetaType::Void, 0, 0));
-
- COPY_TEST(bool, Bool, true, false);
- COPY_TEST(int, Int, 10, 0);
- COPY_TEST(unsigned int, UInt, 10, 0);
- COPY_TEST(long long, LongLong, 10, 0);
- COPY_TEST(unsigned long long, ULongLong, 10, 0);
- COPY_TEST(double, Double, 19.2, 0);
-
- QT_COPY_TEST(QChar, QChar('a'));
-
- QVariantMap variantMap;
- variantMap.insert("Hello World!", QVariant(10));
- QT_COPY_TEST(QVariantMap, variantMap);
-
- QT_COPY_TEST(QVariantList, QVariantList() << QVariant(19.2));
- QT_COPY_TEST(QString, QString("QML Rocks!"));
- QT_COPY_TEST(QStringList, QStringList() << "QML" << "Rocks");
- QT_COPY_TEST(QByteArray, QByteArray("0x1102DDD"));
- QT_COPY_TEST(QBitArray, QBitArray(102, true));
- QDate cd = QDate::currentDate();
- QT_COPY_TEST(QDate, cd);
- QTime ct = QTime::currentTime();
- QT_COPY_TEST(QTime, ct);
- QDateTime cdt = QDateTime::currentDateTime();
- QT_COPY_TEST(QDateTime, cdt);
- QT_COPY_TEST(QUrl, QUrl("http://www.nokia.com"));
- QT_COPY_TEST(QLocale, QLocale(QLocale::English, QLocale::Australia));
- QT_COPY_TEST(QRect, QRect(-10, 10, 102, 99));
- QT_COPY_TEST(QRectF, QRectF(-10.2, 1.2, 102, 99.6));
- QT_COPY_TEST(QSize, QSize(100, 2));
- QT_COPY_TEST(QSizeF, QSizeF(20.2, -100234.2));
- QT_COPY_TEST(QLine, QLine(0, 0, 100, 100));
- QT_COPY_TEST(QLineF, QLineF(-10.2, 0, 103, 1));
- QT_COPY_TEST(QPoint, QPoint(-1912, 1613));
- QT_COPY_TEST(QPointF, QPointF(-908.1, 1612));
- QT_COPY_TEST(QRegExp, QRegExp("(\\d+)(?:\\s*)(cm|inch)"));
-
- QVariantHash variantHash;
- variantHash.insert("Hello World!", QVariant(19));
- QT_COPY_TEST(QVariantHash, variantHash);
-
-#ifdef QT3_SUPPORT
- QT_COPY_TEST(QColorGroup, QColorGroup(Qt::red, Qt::red, Qt::red, Qt::red, Qt::red, Qt::red, Qt::red));
-#endif
-
- QT_COPY_TEST(QFont, QFont("Helvetica", 1024));
-
- {
- QPixmap v = QPixmap(100, 100); QPixmap v2 = QPixmap(100, 100);
- QVERIFY(QmlMetaType::copy(QMetaType::QPixmap, &v, 0));
- QVERIFY(v.size() == QPixmap().size());
- QVERIFY(QmlMetaType::copy(QMetaType::QPixmap , &v, &v2));
- QVERIFY(v.size() == QPixmap(100,100).size());
- }
-
- QT_COPY_TEST(QBrush, QBrush(Qt::blue));
- QT_COPY_TEST(QColor, QColor("lightsteelblue"));
- QT_COPY_TEST(QPalette, QPalette(Qt::green));
-
- {
- QPixmap icon(100, 100);
-
- QIcon v = QIcon(icon); QIcon v2 = QIcon(icon);
- QVERIFY(QmlMetaType::copy(QMetaType::QIcon, &v, 0));
- QVERIFY(v.isNull() == QIcon().isNull());
- QVERIFY(QmlMetaType::copy(QMetaType::QIcon , &v, &v2));
- QVERIFY(v.isNull() == QIcon(icon).isNull());
- }
-
- {
- QImage v = QImage(100, 100, QImage::Format_RGB32);
- QImage v2 = QImage(100, 100, QImage::Format_RGB32);
- QVERIFY(QmlMetaType::copy(QMetaType::QImage, &v, 0));
- QVERIFY(v.size() == QImage().size());
- QVERIFY(QmlMetaType::copy(QMetaType::QImage , &v, &v2));
- QVERIFY(v.size() == QImage(100,100, QImage::Format_RGB32).size());
- }
-
- QT_COPY_TEST(QPolygon, QPolygon(QRect(100, 100, 200, 103)));
- QT_COPY_TEST(QRegion, QRegion(QRect(0, 10, 99, 87)));
-
- {
- QBitmap v = QBitmap(100, 100); QBitmap v2 = QBitmap(100, 100);
- QVERIFY(QmlMetaType::copy(QMetaType::QBitmap, &v, 0));
- QVERIFY(v.size() == QBitmap().size());
- QVERIFY(QmlMetaType::copy(QMetaType::QBitmap , &v, &v2));
- QVERIFY(v.size() == QBitmap(100,100).size());
- }
-
- {
- QCursor v = QCursor(Qt::SizeFDiagCursor); QCursor v2 = QCursor(Qt::SizeFDiagCursor);
- QVERIFY(QmlMetaType::copy(QMetaType::QCursor, &v, 0));
- QVERIFY(v.shape() == QCursor().shape());
- QVERIFY(QmlMetaType::copy(QMetaType::QCursor , &v, &v2));
- QVERIFY(v.shape() == QCursor(Qt::SizeFDiagCursor).shape());
- }
-
- QT_COPY_TEST(QSizePolicy, QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Maximum));
- QT_COPY_TEST(QKeySequence, QKeySequence("Ctrl+O"));
- QT_COPY_TEST(QPen, QPen(Qt::red));
- QT_COPY_TEST(QTextLength, QTextLength(QTextLength::FixedLength, 10.2));
- QT_COPY_TEST(QTextFormat, QTextFormat(QTextFormat::ListFormat));
- QT_COPY_TEST(QMatrix, QMatrix().translate(10, 10));
- QT_COPY_TEST(QTransform, QTransform().translate(10, 10));
- QT_COPY_TEST(QMatrix4x4, QMatrix4x4(1,0,2,3,0,1,0,0,9,0,1,0,0,0,10,1));
- QT_COPY_TEST(QVector2D, QVector2D(10.2, 1));
- QT_COPY_TEST(QVector3D, QVector3D(10.2, 1, -2));
- QT_COPY_TEST(QVector4D, QVector4D(10.2, 1, -2, 1.2));
- QT_COPY_TEST(QQuaternion, QQuaternion(1.0, 10.2, 1, -2));
-
- int voidValue;
- COPY_TEST(void *, VoidStar, (void *)&voidValue, (void *)0);
- COPY_TEST(long, Long, 10, 0);
- COPY_TEST(short, Short, 10, 0);
- COPY_TEST(char, Char, 'a', 0);
- COPY_TEST(unsigned long, ULong, 10, 0);
- COPY_TEST(unsigned short, UShort, 10, 0);
- COPY_TEST(unsigned char, UChar, 'a', 0);
- COPY_TEST(float, Float, 10.5, 0);
-
- QObject objectValue;
- QWidget widgetValue;
- COPY_TEST(QObject *, QObjectStar, &objectValue, 0);
- COPY_TEST(QWidget *, QWidgetStar, &widgetValue, 0);
- COPY_TEST(qreal, QReal, 10.2, 0);
-
- {
- QVariant tv = QVariant::fromValue(QVariant(10));
- QVariant v(tv); QVariant v2(tv);
- QVERIFY(QmlMetaType::copy(qMetaTypeId<QVariant>(), &v, 0));
- QVERIFY(v == QVariant());
- QVERIFY(QmlMetaType::copy(qMetaTypeId<QVariant>(), &v, &v2));
- QVERIFY(v == tv);
- }
-
- {
- TestType t; QVariant tv = QVariant::fromValue(&t);
-
- QVariant v(tv); QVariant v2(tv);
- QVERIFY(QmlMetaType::copy(qMetaTypeId<TestType *>(), &v, 0));
- QVERIFY(v == QVariant::fromValue((TestType *)0));
- QVERIFY(QmlMetaType::copy(qMetaTypeId<TestType *>(), &v, &v2));
- QVERIFY(v == tv);
- }
-}
-
-void tst_qmlmetatype::qmlParserStatusCast()
-{
- QVERIFY(QmlMetaType::qmlType(QVariant::Int) == 0);
- QVERIFY(QmlMetaType::qmlType(qMetaTypeId<TestType *>()) != 0);
- QCOMPARE(QmlMetaType::qmlType(qMetaTypeId<TestType *>())->parserStatusCast(), -1);
- QVERIFY(QmlMetaType::qmlType(qMetaTypeId<ValueSourceTestType *>()) != 0);
- QCOMPARE(QmlMetaType::qmlType(qMetaTypeId<ValueSourceTestType *>())->parserStatusCast(), -1);
-
- QVERIFY(QmlMetaType::qmlType(qMetaTypeId<ParserStatusTestType *>()) != 0);
- int cast = QmlMetaType::qmlType(qMetaTypeId<ParserStatusTestType *>())->parserStatusCast();
- QVERIFY(cast != -1);
- QVERIFY(cast != 0);
-
- ParserStatusTestType t;
- QVERIFY(reinterpret_cast<char *>((QObject *)&t) != reinterpret_cast<char *>((QmlParserStatus *)&t));
-
- QmlParserStatus *status = reinterpret_cast<QmlParserStatus *>(reinterpret_cast<char *>((QObject *)&t) + cast);
- QCOMPARE(status, &t);
-}
-
-void tst_qmlmetatype::qmlPropertyValueSourceCast()
-{
- QVERIFY(QmlMetaType::qmlType(QVariant::Int) == 0);
- QVERIFY(QmlMetaType::qmlType(qMetaTypeId<TestType *>()) != 0);
- QCOMPARE(QmlMetaType::qmlType(qMetaTypeId<TestType *>())->propertyValueSourceCast(), -1);
- QVERIFY(QmlMetaType::qmlType(qMetaTypeId<ParserStatusTestType *>()) != 0);
- QCOMPARE(QmlMetaType::qmlType(qMetaTypeId<ParserStatusTestType *>())->propertyValueSourceCast(), -1);
-
- QVERIFY(QmlMetaType::qmlType(qMetaTypeId<ValueSourceTestType *>()) != 0);
- int cast = QmlMetaType::qmlType(qMetaTypeId<ValueSourceTestType *>())->propertyValueSourceCast();
- QVERIFY(cast != -1);
- QVERIFY(cast != 0);
-
- ValueSourceTestType t;
- QVERIFY(reinterpret_cast<char *>((QObject *)&t) != reinterpret_cast<char *>((QmlPropertyValueSource *)&t));
-
- QmlPropertyValueSource *source = reinterpret_cast<QmlPropertyValueSource *>(reinterpret_cast<char *>((QObject *)&t) + cast);
- QCOMPARE(source, &t);
-}
-
-void tst_qmlmetatype::qmlPropertyValueInterceptorCast()
-{
- QVERIFY(QmlMetaType::qmlType(QVariant::Int) == 0);
- QVERIFY(QmlMetaType::qmlType(qMetaTypeId<TestType *>()) != 0);
- QCOMPARE(QmlMetaType::qmlType(qMetaTypeId<TestType *>())->propertyValueInterceptorCast(), -1);
- QVERIFY(QmlMetaType::qmlType(qMetaTypeId<ParserStatusTestType *>()) != 0);
- QCOMPARE(QmlMetaType::qmlType(qMetaTypeId<ParserStatusTestType *>())->propertyValueInterceptorCast(), -1);
-
- QVERIFY(QmlMetaType::qmlType(qMetaTypeId<ValueInterceptorTestType *>()) != 0);
- int cast = QmlMetaType::qmlType(qMetaTypeId<ValueInterceptorTestType *>())->propertyValueInterceptorCast();
- QVERIFY(cast != -1);
- QVERIFY(cast != 0);
-
- ValueInterceptorTestType t;
- QVERIFY(reinterpret_cast<char *>((QObject *)&t) != reinterpret_cast<char *>((QmlPropertyValueInterceptor *)&t));
-
- QmlPropertyValueInterceptor *interceptor = reinterpret_cast<QmlPropertyValueInterceptor *>(reinterpret_cast<char *>((QObject *)&t) + cast);
- QCOMPARE(interceptor, &t);
-}
-
-void tst_qmlmetatype::isList()
-{
- QCOMPARE(QmlMetaType::isList(QVariant::Invalid), false);
- QCOMPARE(QmlMetaType::isList(QVariant::Int), false);
-
- QmlListProperty<TestType> list;
-
- QCOMPARE(QmlMetaType::isList(qMetaTypeId<QmlListProperty<TestType> >()), true);
-}
-
-void tst_qmlmetatype::defaultObject()
-{
- QVERIFY(QmlMetaType::defaultProperty(&QObject::staticMetaObject).name() == 0);
- QVERIFY(QmlMetaType::defaultProperty(&ParserStatusTestType::staticMetaObject).name() == 0);
- QCOMPARE(QString(QmlMetaType::defaultProperty(&TestType::staticMetaObject).name()), QString("foo"));
-
- QObject o;
- TestType t;
- ParserStatusTestType p;
-
- QVERIFY(QmlMetaType::defaultProperty((QObject *)0).name() == 0);
- QVERIFY(QmlMetaType::defaultProperty(&o).name() == 0);
- QVERIFY(QmlMetaType::defaultProperty(&p).name() == 0);
- QCOMPARE(QString(QmlMetaType::defaultProperty(&t).name()), QString("foo"));
-}
-
-QTEST_MAIN(tst_qmlmetatype)
-
-#include "tst_qmlmetatype.moc"
diff --git a/tests/auto/declarative/qmlmoduleplugin/plugin/plugin.cpp b/tests/auto/declarative/qmlmoduleplugin/plugin/plugin.cpp
deleted file mode 100644
index 0d7f985..0000000
--- a/tests/auto/declarative/qmlmoduleplugin/plugin/plugin.cpp
+++ /dev/null
@@ -1,84 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <QtDeclarative/qmlmoduleplugin.h>
-#include <QtDeclarative/qml.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;
-};
-
-QML_DECLARE_TYPE(MyPluginType);
-QML_DEFINE_TYPE(com.nokia.AutoTestQmlPluginType,1,0,MyPluginType,MyPluginType);
-
-
-class MyPlugin : public QmlModulePlugin
-{
- Q_OBJECT
-public:
- MyPlugin()
- {
- qWarning("plugin created");
- }
-
- QStringList keys() const
- {
- return QStringList() << QLatin1String("com.nokia.AutoTestQmlPluginType");
- }
-};
-
-#include "plugin.moc"
-
-Q_EXPORT_PLUGIN2(plugin, MyPlugin);
diff --git a/tests/auto/declarative/qmlmoduleplugin/plugin/plugin.pro b/tests/auto/declarative/qmlmoduleplugin/plugin/plugin.pro
deleted file mode 100644
index 0625ea3..0000000
--- a/tests/auto/declarative/qmlmoduleplugin/plugin/plugin.pro
+++ /dev/null
@@ -1,5 +0,0 @@
-TEMPLATE = lib
-CONFIG += plugin
-SOURCES = plugin.cpp
-QT = core declarative
-DESTDIR = qmlmodules
diff --git a/tests/auto/declarative/qmlmoduleplugin/qmlmoduleplugin.pro b/tests/auto/declarative/qmlmoduleplugin/qmlmoduleplugin.pro
deleted file mode 100644
index c60743d..0000000
--- a/tests/auto/declarative/qmlmoduleplugin/qmlmoduleplugin.pro
+++ /dev/null
@@ -1,7 +0,0 @@
-QT = core
-TEMPLATE = subdirs
-SUBDIRS = plugin
-tst_qmlmoduleplugin_pro.depends += plugin
-SUBDIRS += tst_qmlmoduleplugin.pro
-
-
diff --git a/tests/auto/declarative/qmlmoduleplugin/tst_qmlmoduleplugin.cpp b/tests/auto/declarative/qmlmoduleplugin/tst_qmlmoduleplugin.cpp
deleted file mode 100644
index 87125fc..0000000
--- a/tests/auto/declarative/qmlmoduleplugin/tst_qmlmoduleplugin.cpp
+++ /dev/null
@@ -1,117 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <qdir.h>
-#include <QtDeclarative/qmlengine.h>
-#include <QtDeclarative/qmlcomponent.h>
-#include <QDebug>
-
-class tst_qmlmoduleplugin : public QObject
-{
- Q_OBJECT
-public:
- tst_qmlmoduleplugin() {
- QCoreApplication::addLibraryPath(QLatin1String(SRCDIR) + QDir::separator() + QLatin1String("plugin"));
-qDebug() << QLatin1String(SRCDIR) + QDir::separator() + QLatin1String("plugin");
- }
-
-private slots:
- void importsPlugin();
-};
-
-#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 { \
- QFile file(QLatin1String("data/") + QLatin1String(errorfile)); \
- QVERIFY(file.open(QIODevice::ReadOnly)); \
- QByteArray data = file.readAll(); \
- file.close(); \
- QList<QByteArray> expected = data.split('\n'); \
- expected.removeAll(QByteArray("")); \
- QList<QmlError> errors = component.errors(); \
- QList<QByteArray> actual; \
- for (int ii = 0; ii < errors.count(); ++ii) { \
- const QmlError &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("QMLLANGUAGE_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)
-{
- QFileInfo fileInfo(__FILE__);
- return QUrl::fromLocalFile(fileInfo.absoluteDir().filePath(filename));
-}
-
-
-void tst_qmlmoduleplugin::importsPlugin()
-{
- QmlEngine engine;
- QTest::ignoreMessage(QtWarningMsg, "plugin created");
- QTest::ignoreMessage(QtWarningMsg, "import worked");
- QmlComponent component(&engine, TEST_FILE("plugin.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
- QCOMPARE(object->property("value").toInt(),123);
-}
-
-QTEST_MAIN(tst_qmlmoduleplugin)
-
-#include "tst_qmlmoduleplugin.moc"
diff --git a/tests/auto/declarative/qmlmoduleplugin/tst_qmlmoduleplugin.pro b/tests/auto/declarative/qmlmoduleplugin/tst_qmlmoduleplugin.pro
deleted file mode 100644
index 3c8a568..0000000
--- a/tests/auto/declarative/qmlmoduleplugin/tst_qmlmoduleplugin.pro
+++ /dev/null
@@ -1,4 +0,0 @@
-load(qttest_p4)
-SOURCES = tst_qmlmoduleplugin.cpp
-QT += declarative
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmlnumberformatter/qmlnumberformatter.pro b/tests/auto/declarative/qmlnumberformatter/qmlnumberformatter.pro
deleted file mode 100644
index 8113278..0000000
--- a/tests/auto/declarative/qmlnumberformatter/qmlnumberformatter.pro
+++ /dev/null
@@ -1,5 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qmlnumberformatter.cpp
diff --git a/tests/auto/declarative/qmlnumberformatter/tst_qmlnumberformatter.cpp b/tests/auto/declarative/qmlnumberformatter/tst_qmlnumberformatter.cpp
deleted file mode 100644
index 30f2fea..0000000
--- a/tests/auto/declarative/qmlnumberformatter/tst_qmlnumberformatter.cpp
+++ /dev/null
@@ -1,222 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QDebug>
-#include <QtDeclarative/qmlengine.h>
-#include <QtDeclarative/qmlcomponent.h>
-#include <private/qnumberformat_p.h>
-#include <private/qmlnumberformatter_p.h>
-
-class tst_qmlnumberformatter : public QObject
-{
- Q_OBJECT
-public:
- tst_qmlnumberformatter();
-
- void init() {}
- void initTestCase() {}
-
- void cleanup() {}
- void cleanupTestCase() {}
-
-private slots:
- void text_data();
- void text();
-
-private:
- QStringList strings;
- QStringList formats;
- QStringList texts;
-};
-
-tst_qmlnumberformatter::tst_qmlnumberformatter()
-{
- strings << "100.0"
- << "12345"
- << "1234567"
- << "0.123"
- << "0.9999"
- << "0.989"
- << "1"
- << "1.0"
- << "1.01";
-
- formats << ""
- << "0000"
- << "0000.00"
- << "##"
- << "##.##"
- << "#0.00#"
- << "##,##0.##"
- << "(000) 000 - 000"
- << "00000,000.0000";
-
- //US locale only.
- texts << "100.000000"
- << "12345.000000"
- << "1234567.000000"
- << "0.123000"
- << "0.999900"
- << "0.989000"
- << "1.000000"
- << "1.000000"
- << "1.010000" //end ""
- << "0100"
- << "12345"
- << "1234567"
- << "0000"
- << "0001"
- << "0001"
- << "0001"
- << "0001"
- << "0001" // end "0000"
- << "0100.00"
- << "12345.00"
- << "1234567.00"
- << "0000.12"
- << "0001.00"
- << "0000.99"
- << "0001.00"
- << "0001.00"
- << "0001.01" // end "0000.00"
- << "100"
- << "12345"
- << "1234567"
- << "0"
- << "1"
- << "1"
- << "1"
- << "1"
- << "1" // end "##"
- << "100"//start "##.##"
- << "12345"
- << "1234567"
- << "0.12"
- << "1"
- << "0.99"
- << "1"
- << "1"
- << "1.01" // end "##.##" -- ### EXPECT FAIL ### QNumberFormat::formatDecimal() bug
- << "100.00" //start "#0.00#"
- << "12345.00"
- << "1234567.00"
- << "0.123"
- << "1.00"
- << "0.989"
- << "1.00"
- << "1.00"
- << "1.01" //end "#0.00#"
- << "100" //start "##,##0.##"
- << "12,345"
- << "1,234,567"
- << "0.12"
- << "1"
- << "0.99"
- << "1"
- << "1"
- << "1.01" //end "##,##0.##" -- ### EXPECT FAIL ### QNumberFormat::formatDecimal() bug
- << "(000) 000 - 100" //start "(000) 000 - 000"
- << "(000) 012 - 345"
- << "(001) 234 - 567"
- << "(000) 000 - 000"
- << "(000) 000 - 001"
- << "(000) 000 - 001"
- << "(000) 000 - 001"
- << "(000) 000 - 001"
- << "(000) 000 - 001" // end "(000) 000 - 000"
- << "00,000,100.0000" // start "00000,000.0000"
- << "00,012,345.0000"
- << "01,234,567.0000"
- << "00,000,000.1230"
- << "00,000,000.9999"
- << "00,000,000.9890"
- << "00,000,001.0000"
- << "00,000,001.0000"
- << "00,000,001.0100"; // end
-
- qDebug() << "strings.size()" << strings.size()
- << "\nformats.size()" << formats.size()
- << "texts.size()" << texts.size();
-}
-
-void tst_qmlnumberformatter::text_data()
-{
- QTest::addColumn<QString>("string");
- QTest::addColumn<QString>("format");
- QTest::addColumn<QString>("text");
-
- for (int j=0; j < formats.size(); j++)
- {
- for (int i=0; i < strings.size(); i++)
- {
- QTest::newRow(QString("%1, %2").arg(strings.at(i)).arg(formats.at(j)).toAscii())
- << strings.at(i) << formats.at(j) << texts.at(j*formats.size()+i);
- }
- }
-
-}
-
-void tst_qmlnumberformatter::text()
-{
- QFETCH(QString, string);
- QFETCH(QString, format);
- QFETCH(QString, text);
-
- QString componentStr = QString("import Qt 4.6\nNumberFormatter { number: ") + string + QString("; format: \"") + format + QString("\" }");
-
- QmlEngine engine;
- QmlComponent formatterComponent(&engine);
- formatterComponent.setData(componentStr.toUtf8(), QUrl::fromLocalFile(""));
- if(formatterComponent.isError())
- qDebug() << formatterComponent.errors();
- QVERIFY(formatterComponent.isReady());
- QmlNumberFormatter *formatter = qobject_cast<QmlNumberFormatter*>(formatterComponent.create());
- QVERIFY(formatter != 0);
-
- QCOMPARE(formatter->format(), format);
- QCOMPARE(formatter->text(), text);
-
- delete formatter;
-}
-
-QTEST_MAIN(tst_qmlnumberformatter)
-
-#include "tst_qmlnumberformatter.moc"
diff --git a/tests/auto/declarative/qmlpixmapcache/qmlpixmapcache.pro b/tests/auto/declarative/qmlpixmapcache/qmlpixmapcache.pro
deleted file mode 100644
index 423fa2f..0000000
--- a/tests/auto/declarative/qmlpixmapcache/qmlpixmapcache.pro
+++ /dev/null
@@ -1,9 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative
-QT += network
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qmlpixmapcache.cpp
-
-# QMAKE_CXXFLAGS = -fprofile-arcs -ftest-coverage
-# LIBS += -lgcov
diff --git a/tests/auto/declarative/qmlpixmapcache/tst_qmlpixmapcache.cpp b/tests/auto/declarative/qmlpixmapcache/tst_qmlpixmapcache.cpp
deleted file mode 100644
index 019fc2a..0000000
--- a/tests/auto/declarative/qmlpixmapcache/tst_qmlpixmapcache.cpp
+++ /dev/null
@@ -1,282 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtTest/QtTest>
-#include <private/qmlpixmapcache_p.h>
-#include <QtDeclarative/qmlengine.h>
-#include <QNetworkReply>
-
-// These don't let normal people run tests!
-//#include "../network-settings.h"
-
-class tst_qmlpixmapcache : public QObject
-{
- Q_OBJECT
-public:
- tst_qmlpixmapcache() :
- thisfile(QUrl::fromLocalFile(__FILE__))
- {
- }
-
-private slots:
- void single();
- void single_data();
- void parallel();
- void parallel_data();
-
-private:
- QmlEngine engine;
- QUrl thisfile;
-};
-
-
-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_qmlpixmapcache::single_data()
-{
- // Note, since QmlPixmapCache 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") << thisfile.resolved(QUrl("data/exists.png")) << localfile_optimized << true << false;
- QTest::newRow("local") << thisfile.resolved(QUrl("data/notexists.png")) << localfile_optimized << false << false;
- QTest::newRow("remote") << QUrl("http://qt.nokia.com/logo.png") << false << true << false;
- QTest::newRow("remote") << QUrl("http://qt.nokia.com/thereisnologo.png") << false << false << true;
-}
-
-void tst_qmlpixmapcache::single()
-{
- QFETCH(QUrl, target);
- QFETCH(bool, incache);
- QFETCH(bool, exists);
- QFETCH(bool, neterror);
-
- if (neterror) {
- QString expected = "\"Error downloading " + target.toString() + " - server replied: Not Found\" ";
- QTest::ignoreMessage(QtWarningMsg, expected.toLatin1());
- } else if (!exists) {
- QString expected = "Cannot open QUrl( \"" + target.toString() + "\" ) ";
- QTest::ignoreMessage(QtWarningMsg, expected.toLatin1());
- }
-
- QPixmap pixmap;
- QVERIFY(pixmap.width() <= 0); // Check Qt assumption
- QmlPixmapReply::Status status = QmlPixmapCache::get(target, &pixmap);
-
- if (incache) {
- if (exists) {
- QVERIFY(status == QmlPixmapReply::Ready);
- QVERIFY(pixmap.width() > 0);
- } else {
- QVERIFY(status == QmlPixmapReply::Error);
- QVERIFY(pixmap.width() <= 0);
- }
- } else {
- QmlPixmapReply *reply = QmlPixmapCache::request(&engine, target);
- QVERIFY(reply);
- QVERIFY(pixmap.width() <= 0);
-
- Slotter getter;
- connect(reply, SIGNAL(finished()), &getter, SLOT(got()));
- QTestEventLoop::instance().enterLoop(10);
- QVERIFY(!QTestEventLoop::instance().timeout());
- QVERIFY(getter.gotslot);
- if (exists) {
- QVERIFY(QmlPixmapCache::get(target, &pixmap) == QmlPixmapReply::Ready);
- QVERIFY(pixmap.width() > 0);
- } else {
- QVERIFY(QmlPixmapCache::get(target, &pixmap) == QmlPixmapReply::Error);
- QVERIFY(pixmap.width() <= 0);
- }
- }
-
- QCOMPARE(QmlPixmapCache::pendingRequests(), 0);
-}
-
-void tst_qmlpixmapcache::parallel_data()
-{
- // Note, since QmlPixmapCache 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::addColumn<int>("requests");
-
- QTest::newRow("local")
- << thisfile.resolved(QUrl("data/exists1.png"))
- << thisfile.resolved(QUrl("data/exists2.png"))
- << (localfile_optimized ? 2 : 0)
- << -1
- << (localfile_optimized ? 0 : 2)
- ;
-
- QTest::newRow("remote")
- << QUrl("http://qt.nokia.com/images/template/checkbox-on.png")
- << QUrl("http://qt.nokia.com/images/products/qt-logo/image_tile")
- << 0
- << -1
- << 2
- ;
-
- QTest::newRow("remoteagain")
- << QUrl("http://qt.nokia.com/images/template/checkbox-on.png")
- << QUrl("http://qt.nokia.com/images/products/qt-logo/image_tile")
- << 2
- << -1
- << 0
- ;
-
- QTest::newRow("remotecopy")
- << QUrl("http://qt.nokia.com/images/template/checkbox-off.png")
- << QUrl("http://qt.nokia.com/images/template/checkbox-off.png")
- << 0
- << -1
- << 1
- ;
-
- QTest::newRow("remotecopycancel")
- << QUrl("http://qt.nokia.com/rounded_block_bg.png")
- << QUrl("http://qt.nokia.com/rounded_block_bg.png")
- << 0
- << 0
- << 1
- ;
-}
-
-void tst_qmlpixmapcache::parallel()
-{
- QFETCH(QUrl, target1);
- QFETCH(QUrl, target2);
- QFETCH(int, incache);
- QFETCH(int, cancel);
- QFETCH(int, requests);
-
- QList<QUrl> targets;
- targets << target1 << target2;
-
- QList<QmlPixmapReply*> replies;
- QList<Slotter*> getters;
- for (int i=0; i<targets.count(); ++i) {
- QUrl target = targets.at(i);
- QPixmap pixmap;
- QmlPixmapReply::Status status = QmlPixmapCache::get(target, &pixmap);
- QmlPixmapReply *reply = 0;
- if (status != QmlPixmapReply::Error && status != QmlPixmapReply::Ready)
- reply = QmlPixmapCache::request(&engine, target);
- replies.append(reply);
- if (!reply) {
- QVERIFY(pixmap.width() > 0);
- getters.append(0);
- } else {
- QVERIFY(pixmap.width() <= 0);
- getters.append(new Slotter);
- connect(reply, SIGNAL(finished()), getters[i], SLOT(got()));
- }
- }
-
- QCOMPARE(incache+slotters, targets.count());
- QCOMPARE(QmlPixmapCache::pendingRequests(), requests);
-
- if (cancel >= 0) {
- QmlPixmapCache::cancel(targets.at(cancel), getters[cancel]);
- slotters--;
- }
-
- if (slotters) {
- QTestEventLoop::instance().enterLoop(10);
- QVERIFY(!QTestEventLoop::instance().timeout());
- }
-
- for (int i=0; i<targets.count(); ++i) {
- QmlPixmapReply *reply = replies[i];
- if (reply) {
- if (i == cancel) {
- QVERIFY(!getters[i]->gotslot);
- } else {
- QVERIFY(getters[i]->gotslot);
- QPixmap pixmap;
- QVERIFY(QmlPixmapCache::get(targets[i], &pixmap) == QmlPixmapReply::Ready);
- QVERIFY(pixmap.width() > 0);
- }
- delete getters[i];
- }
- }
-
- QCOMPARE(QmlPixmapCache::pendingRequests(), 0);
-}
-
-QTEST_MAIN(tst_qmlpixmapcache)
-
-#include "tst_qmlpixmapcache.moc"
diff --git a/tests/auto/declarative/qmlpropertymap/qmlpropertymap.pro b/tests/auto/declarative/qmlpropertymap/qmlpropertymap.pro
deleted file mode 100644
index 967ab76..0000000
--- a/tests/auto/declarative/qmlpropertymap/qmlpropertymap.pro
+++ /dev/null
@@ -1,5 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qmlpropertymap.cpp
diff --git a/tests/auto/declarative/qmlpropertymap/tst_qmlpropertymap.cpp b/tests/auto/declarative/qmlpropertymap/tst_qmlpropertymap.cpp
deleted file mode 100644
index 26b89a6..0000000
--- a/tests/auto/declarative/qmlpropertymap/tst_qmlpropertymap.cpp
+++ /dev/null
@@ -1,171 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtDeclarative/qmlengine.h>
-#include <QtDeclarative/qmlcontext.h>
-#include <QtDeclarative/qmlpropertymap.h>
-#include <QtDeclarative/qmlcomponent.h>
-#include <private/qmlgraphicstext_p.h>
-#include <QSignalSpy>
-
-class tst_QmlPropertyMap : public QObject
-{
- Q_OBJECT
-public:
- tst_QmlPropertyMap() {}
-
-private slots:
- void insert();
- void operatorInsert();
- void operatorValue();
- void clear();
- void changed();
- void count();
-};
-
-void tst_QmlPropertyMap::insert()
-{
- QmlPropertyMap 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"));
-}
-
-void tst_QmlPropertyMap::operatorInsert()
-{
- QmlPropertyMap 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_QmlPropertyMap::operatorValue()
-{
- QmlPropertyMap map;
- map.insert(QLatin1String("key1"),100);
- map.insert(QLatin1String("key2"),200);
- QVERIFY(map.count() == 2);
- QVERIFY(map.contains(QLatin1String("key1")));
-
- const QmlPropertyMap &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_QmlPropertyMap::clear()
-{
- QmlPropertyMap 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_QmlPropertyMap::changed()
-{
- QmlPropertyMap map;
- QSignalSpy spy(&map, SIGNAL(valueChanged(const QString&)));
- 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
- QmlEngine engine;
- QmlContext *ctxt = engine.rootContext();
- ctxt->setContextProperty(QLatin1String("testdata"), &map);
- QmlComponent component(&engine);
- component.setData("import Qt 4.6\nText { text: { testdata.key1 = 'Hello World'; 'X' } }",
- QUrl::fromLocalFile(""));
- QVERIFY(component.isReady());
- QmlGraphicsText *txt = qobject_cast<QmlGraphicsText*>(component.create());
- QVERIFY(txt);
- QCOMPARE(txt->text(), QString('X'));
- QCOMPARE(spy.count(), 1);
- QList<QVariant> arguments = spy.takeFirst();
- QCOMPARE(arguments.at(0).toString(),QLatin1String("key1"));
- QCOMPARE(map.value(QLatin1String("key1")), QVariant("Hello World"));
-}
-
-void tst_QmlPropertyMap::count()
-{
- QmlPropertyMap 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());
-}
-
-QTEST_MAIN(tst_QmlPropertyMap)
-
-#include "tst_qmlpropertymap.moc"
diff --git a/tests/auto/declarative/qmlqt/qmlqt.pro b/tests/auto/declarative/qmlqt/qmlqt.pro
deleted file mode 100644
index 5e79ea6..0000000
--- a/tests/auto/declarative/qmlqt/qmlqt.pro
+++ /dev/null
@@ -1,9 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative
-SOURCES += tst_qmlqt.cpp
-macx:CONFIG -= app_bundle
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
-
-# QMAKE_CXXFLAGS = -fprofile-arcs -ftest-coverage
-# LIBS += -lgcov
diff --git a/tests/auto/declarative/qmlqt/tst_qmlqt.cpp b/tests/auto/declarative/qmlqt/tst_qmlqt.cpp
deleted file mode 100644
index c3c2521..0000000
--- a/tests/auto/declarative/qmlqt/tst_qmlqt.cpp
+++ /dev/null
@@ -1,369 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qtest.h>
-#include <QDebug>
-#include <QmlEngine>
-#include <QFileInfo>
-#include <QmlComponent>
-#include <QDir>
-#include <QVector3D>
-#include <QCryptographicHash>
-#include <QmlGraphicsItem>
-
-class tst_qmlqt : public QObject
-{
- Q_OBJECT
-public:
- tst_qmlqt() {}
-
-private slots:
- void enums();
- void rgba();
- void hsla();
- void rect();
- void point();
- void size();
- void vector();
- void lighter();
- void darker();
- void tint();
- void closestAngle();
- void playSound();
- void openUrlExternally();
- void md5();
- void createComponent();
- void createQmlObject();
- void consoleLog();
-
-private:
- QmlEngine engine;
-};
-
-inline QUrl TEST_FILE(const QString &filename)
-{
- return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename);
-}
-
-void tst_qmlqt::enums()
-{
- QmlComponent component(&engine, TEST_FILE("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_qmlqt::rgba()
-{
- QmlComponent component(&engine, TEST_FILE("rgba.qml"));
-
- QString warning1 = component.url().toString() + ":6: Unable to assign null to QColor";
- QString warning2 = component.url().toString() + ":7: Unable to assign null to QColor";
- QString warning3 = component.url().toString() + ":8: Unable to assign null to QColor";
- QString warning4 = component.url().toString() + ":9: Unable to assign null to QColor";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning3));
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning4));
-
- 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());
- QCOMPARE(qvariant_cast<QColor>(object->property("test6")), QColor());
-
- delete object;
-}
-
-void tst_qmlqt::hsla()
-{
- QmlComponent component(&engine, TEST_FILE("hsla.qml"));
-
- QString warning1 = component.url().toString() + ":6: Unable to assign null to QColor";
- QString warning2 = component.url().toString() + ":7: Unable to assign null to QColor";
- QString warning3 = component.url().toString() + ":8: Unable to assign null to QColor";
- QString warning4 = component.url().toString() + ":9: Unable to assign null to QColor";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning3));
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning4));
-
- 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());
- QCOMPARE(qvariant_cast<QColor>(object->property("test6")), QColor());
-
- delete object;
-}
-
-void tst_qmlqt::rect()
-{
- QmlComponent component(&engine, TEST_FILE("rect.qml"));
- 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());
-
- delete object;
-}
-
-void tst_qmlqt::point()
-{
- QmlComponent component(&engine, TEST_FILE("point.qml"));
- 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_qmlqt::size()
-{
- QmlComponent component(&engine, TEST_FILE("size.qml"));
- 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_qmlqt::vector()
-{
- QmlComponent component(&engine, TEST_FILE("vector.qml"));
- 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_qmlqt::lighter()
-{
- QmlComponent component(&engine, TEST_FILE("lighter.qml"));
- 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());
- 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_qmlqt::darker()
-{
- QmlComponent component(&engine, TEST_FILE("darker.qml"));
- 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());
- 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_qmlqt::tint()
-{
- QmlComponent component(&engine, TEST_FILE("tint.qml"));
-
- QString warning1 = component.url().toString() + ":7: Unable to assign null to QColor";
- QString warning2 = component.url().toString() + ":8: Unable to assign null to QColor";
- 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));
- QEXPECT_FAIL("", "QT-2424",Continue);
- QCOMPARE(qvariant_cast<QColor>(object->property("test3")), QColor::fromRgbF(1, 0, 0));
- QCOMPARE(qvariant_cast<QColor>(object->property("test4")), QColor());
- QCOMPARE(qvariant_cast<QColor>(object->property("test5")), QColor());
-
- delete object;
-}
-
-void tst_qmlqt::closestAngle()
-{
- QmlComponent component(&engine, TEST_FILE("closestangle.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(qvariant_cast<qreal>(object->property("testSame")), 1.0);
- QCOMPARE(qvariant_cast<qreal>(object->property("testLess")), 1.0);
- QCOMPARE(qvariant_cast<qreal>(object->property("testMore")), 1.0);
- QCOMPARE(qvariant_cast<qreal>(object->property("testFail")), 0.0);
- QCOMPARE(qvariant_cast<qreal>(object->property("test5")), 1.0);
- QCOMPARE(qvariant_cast<qreal>(object->property("test6")), 1.11);
- QCOMPARE(qvariant_cast<qreal>(object->property("test7")), 1.11);
-
- delete object;
-}
-
-void tst_qmlqt::playSound()
-{
- QEXPECT_FAIL("", "How do we test this?", Abort);
- QVERIFY(false);
-}
-
-void tst_qmlqt::openUrlExternally()
-{
- QEXPECT_FAIL("", "How do we test this?", Abort);
- QVERIFY(false);
-}
-
-void tst_qmlqt::md5()
-{
- QmlComponent component(&engine, TEST_FILE("md5.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test1").toString(), QLatin1String(QCryptographicHash::hash(QByteArray(), QCryptographicHash::Md5).toHex()));
- QCOMPARE(object->property("test2").toString(), QLatin1String(QCryptographicHash::hash("Hello World", QCryptographicHash::Md5).toHex()));
-
- delete object;
-}
-
-void tst_qmlqt::createComponent()
-{
- QmlComponent component(&engine, TEST_FILE("createComponent.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("incorrectArgCount1").toBool(), true);
- QCOMPARE(object->property("incorrectArgCount2").toBool(), true);
- QCOMPARE(object->property("emptyArg").toBool(), true);
-
- QCOMPARE(object->property("absoluteUrl").toString(), QString("http://www.example.com/test.qml"));
- QCOMPARE(object->property("relativeUrl").toString(), TEST_FILE("createComponentData.qml").toString());
-
- delete object;
-}
-
-void tst_qmlqt::createQmlObject()
-{
- QmlComponent component(&engine, TEST_FILE("createQmlObject.qml"));
-
- QString warning1 = "QmlEngine::createQmlObject():";
- QString warning2 = " " + TEST_FILE("main.qml").toString() + ":4:1: Duplicate property name";
- QString warning3 = "QmlEngine::createQmlObject(): Component is not ready";
- QString warning4 = "QmlEngine::createQmlObject():";
- QString warning5 = " " + TEST_FILE("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));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("incorrectArgCount1").toBool(), true);
- QCOMPARE(object->property("incorrectArgCount2").toBool(), true);
- QCOMPARE(object->property("emptyArg").toBool(), true);
- QCOMPARE(object->property("errors").toBool(), true);
- QCOMPARE(object->property("noParent").toBool(), true);
- QCOMPARE(object->property("notReady").toBool(), true);
- QCOMPARE(object->property("runtimeError").toBool(), true);
- QCOMPARE(object->property("success").toBool(), true);
-
- QmlGraphicsItem *item = qobject_cast<QmlGraphicsItem *>(object);
- QVERIFY(item != 0);
- QVERIFY(item->childItems().count() == 1);
-
- delete object;
-}
-
-void tst_qmlqt::consoleLog()
-{
- QTest::ignoreMessage(QtDebugMsg, "completed ok");
- QTest::ignoreMessage(QtDebugMsg, "completed ok");
- QmlComponent component(&engine, TEST_FILE("consoleLog.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- delete object;
-}
-
-QTEST_MAIN(tst_qmlqt)
-
-#include "tst_qmlqt.moc"
diff --git a/tests/auto/declarative/qmlspringfollow/qmlspringfollow.pro b/tests/auto/declarative/qmlspringfollow/qmlspringfollow.pro
deleted file mode 100644
index ffaa97f..0000000
--- a/tests/auto/declarative/qmlspringfollow/qmlspringfollow.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative gui
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qmlspringfollow.cpp
-
-# Define SRCDIR equal to test's source directory
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmlspringfollow/tst_qmlspringfollow.cpp b/tests/auto/declarative/qmlspringfollow/tst_qmlspringfollow.cpp
deleted file mode 100644
index 393b351..0000000
--- a/tests/auto/declarative/qmlspringfollow/tst_qmlspringfollow.cpp
+++ /dev/null
@@ -1,137 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtDeclarative/qmlengine.h>
-#include <QtDeclarative/qmlcomponent.h>
-#include <private/qmlspringfollow_p.h>
-#include <private/qmlvaluetype_p.h>
-#include "../../../shared/util.h"
-
-class tst_qmlspringfollow : public QObject
-{
- Q_OBJECT
-public:
- tst_qmlspringfollow();
-
-private slots:
- void defaultValues();
- void values();
- void disabled();
-
-private:
- QmlEngine engine;
-};
-
-tst_qmlspringfollow::tst_qmlspringfollow()
-{
-}
-
-void tst_qmlspringfollow::defaultValues()
-{
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/springfollow1.qml"));
- QmlSpringFollow *obj = qobject_cast<QmlSpringFollow*>(c.create());
-
- QVERIFY(obj != 0);
-
- QCOMPARE(obj->sourceValue(), 0.);
- QCOMPARE(obj->velocity(), 0.);
- QCOMPARE(obj->spring(), 0.);
- QCOMPARE(obj->damping(), 0.);
- QCOMPARE(obj->epsilon(), 0.01);
- QCOMPARE(obj->modulus(), 0.);
- QCOMPARE(obj->value(), 0.);
- QCOMPARE(obj->mass(), 1.);
- QCOMPARE(obj->enabled(), true);
- QCOMPARE(obj->inSync(), true);
-
- delete obj;
-}
-
-void tst_qmlspringfollow::values()
-{
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/springfollow2.qml"));
- QmlSpringFollow *obj = qobject_cast<QmlSpringFollow*>(c.create());
-
- QVERIFY(obj != 0);
-
- QCOMPARE(obj->sourceValue(), 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->enabled(), true);
-
- QTRY_COMPARE(obj->value(), 1.44);
- QTRY_COMPARE(obj->inSync(), true);
-
- delete obj;
-}
-
-void tst_qmlspringfollow::disabled()
-{
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/springfollow3.qml"));
- QmlSpringFollow *obj = qobject_cast<QmlSpringFollow*>(c.create());
-
- QVERIFY(obj != 0);
-
- QCOMPARE(obj->sourceValue(), 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->enabled(), false);
-
- QCOMPARE(obj->value(), 0.0);
- QCOMPARE(obj->inSync(), false);
-
- delete obj;
-}
-
-QTEST_MAIN(tst_qmlspringfollow)
-
-#include "tst_qmlspringfollow.moc"
diff --git a/tests/auto/declarative/qmlstates/qmlstates.pro b/tests/auto/declarative/qmlstates/qmlstates.pro
deleted file mode 100644
index 538734a..0000000
--- a/tests/auto/declarative/qmlstates/qmlstates.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qmlstates.cpp
-
-# Define SRCDIR equal to test's source directory
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmlstates/tst_qmlstates.cpp b/tests/auto/declarative/qmlstates/tst_qmlstates.cpp
deleted file mode 100644
index b910c85..0000000
--- a/tests/auto/declarative/qmlstates/tst_qmlstates.cpp
+++ /dev/null
@@ -1,911 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtDeclarative/qmlengine.h>
-#include <QtDeclarative/qmlcomponent.h>
-#include <private/qmlgraphicsanchors_p_p.h>
-#include <private/qmlgraphicsrectangle_p.h>
-#include <private/qmlpropertychanges_p.h>
-#include <private/qmlstategroup_p.h>
-
-class tst_qmlstates : public QObject
-{
- Q_OBJECT
-public:
- tst_qmlstates() {}
-
-private:
- static QByteArray fullDataPath(const QString &path);
-
-private slots:
- void basicChanges();
- void basicExtension();
- void basicBinding();
- void signalOverride();
- void signalOverrideCrash();
- void parentChange();
- void parentChangeErrors();
- void anchorChanges();
- void anchorChanges2();
- void anchorChanges3();
- void anchorChanges4();
- void anchorChanges5();
- void script();
- void restoreEntryValues();
- void explicitChanges();
- void propertyErrors();
- void incorrectRestoreBug();
- void autoStateAtStartupRestoreBug();
- void deletingChange();
- void deletingState();
- void tempState();
- void illegalTempState();
- void nonExistantProperty();
-};
-
-QByteArray tst_qmlstates::fullDataPath(const QString &path)
-{
- return QUrl::fromLocalFile(SRCDIR + path).toString().toUtf8();
-}
-
-void tst_qmlstates::basicChanges()
-{
- QmlEngine engine;
-
- {
- QmlComponent rectComponent(&engine, SRCDIR "/data/basicChanges.qml");
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QCOMPARE(rect->color(),QColor("red"));
-
- rect->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
-
- rect->setState("");
- QCOMPARE(rect->color(),QColor("red"));
- }
-
- {
- QmlComponent rectComponent(&engine, SRCDIR "/data/basicChanges2.qml");
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QCOMPARE(rect->color(),QColor("red"));
-
- rect->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
-
- rect->setState("green");
- QCOMPARE(rect->color(),QColor("green"));
-
- rect->setState("");
- QCOMPARE(rect->color(),QColor("red"));
-
- rect->setState("green");
- QCOMPARE(rect->color(),QColor("green"));
- }
-
- {
- QmlComponent rectComponent(&engine, SRCDIR "/data/basicChanges3.qml");
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QCOMPARE(rect->color(),QColor("red"));
- QCOMPARE(rect->border()->width(),1);
-
- rect->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
- QCOMPARE(rect->border()->width(),1);
-
- rect->setState("bordered");
- QCOMPARE(rect->color(),QColor("red"));
- QCOMPARE(rect->border()->width(),2);
-
- rect->setState("");
- QCOMPARE(rect->color(),QColor("red"));
- QCOMPARE(rect->border()->width(),1);
- //### we should be checking that this is an implicit rather than explicit 1 (which currently fails)
-
- rect->setState("bordered");
- QCOMPARE(rect->color(),QColor("red"));
- QCOMPARE(rect->border()->width(),2);
-
- rect->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
- QCOMPARE(rect->border()->width(),1);
-
- }
-}
-
-void tst_qmlstates::basicExtension()
-{
- QmlEngine engine;
-
- {
- QmlComponent rectComponent(&engine, SRCDIR "/data/basicExtension.qml");
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QCOMPARE(rect->color(),QColor("red"));
- QCOMPARE(rect->border()->width(),1);
-
- rect->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
- QCOMPARE(rect->border()->width(),1);
-
- rect->setState("bordered");
- QCOMPARE(rect->color(),QColor("blue"));
- QCOMPARE(rect->border()->width(),2);
-
- rect->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
- QCOMPARE(rect->border()->width(),1);
-
- rect->setState("");
- QCOMPARE(rect->color(),QColor("red"));
- QCOMPARE(rect->border()->width(),1);
-
- rect->setState("bordered");
- QCOMPARE(rect->color(),QColor("blue"));
- QCOMPARE(rect->border()->width(),2);
-
- rect->setState("");
- QCOMPARE(rect->color(),QColor("red"));
- QCOMPARE(rect->border()->width(),1);
- }
-
- {
- QmlComponent rectComponent(&engine, SRCDIR "/data/fakeExtension.qml");
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QCOMPARE(rect->color(),QColor("red"));
-
- rect->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
-
- rect->setState("green");
- QCOMPARE(rect->color(),QColor("green"));
-
- rect->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
-
- rect->setState("green");
- QCOMPARE(rect->color(),QColor("green"));
-
- rect->setState("");
- QCOMPARE(rect->color(),QColor("red"));
-
- rect->setState("green");
- QCOMPARE(rect->color(),QColor("green"));
- }
-}
-
-void tst_qmlstates::basicBinding()
-{
- QmlEngine engine;
-
- {
- QmlComponent rectComponent(&engine, SRCDIR "/data/basicBinding.qml");
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QCOMPARE(rect->color(),QColor("red"));
-
- rect->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
-
- rect->setState("");
- QCOMPARE(rect->color(),QColor("red"));
-
- rect->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
- rect->setProperty("sourceColor", QColor("green"));
- QCOMPARE(rect->color(),QColor("green"));
-
- rect->setState("");
- QCOMPARE(rect->color(),QColor("red"));
- rect->setProperty("sourceColor", QColor("yellow"));
- QCOMPARE(rect->color(),QColor("red"));
-
- rect->setState("blue");
- QCOMPARE(rect->color(),QColor("yellow"));
- }
-
- {
- QmlComponent rectComponent(&engine, SRCDIR "/data/basicBinding2.qml");
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QCOMPARE(rect->color(),QColor("red"));
-
- rect->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
-
- rect->setState("");
- QCOMPARE(rect->color(),QColor("red"));
-
- rect->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
- rect->setProperty("sourceColor", QColor("green"));
- QCOMPARE(rect->color(),QColor("blue"));
-
- rect->setState("");
- QCOMPARE(rect->color(),QColor("green"));
- rect->setProperty("sourceColor", QColor("yellow"));
- QCOMPARE(rect->color(),QColor("yellow"));
-
- rect->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
-
- rect->setState("");
- QCOMPARE(rect->color(),QColor("yellow"));
- }
-
- {
- QmlComponent rectComponent(&engine, SRCDIR "/data/basicBinding3.qml");
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QCOMPARE(rect->color(),QColor("red"));
- rect->setProperty("sourceColor", QColor("green"));
- QCOMPARE(rect->color(),QColor("green"));
-
- rect->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"));
-
- rect->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"));
- }
-
- {
- QmlComponent rectComponent(&engine, SRCDIR "/data/basicBinding4.qml");
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QCOMPARE(rect->color(),QColor("red"));
-
- rect->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
- rect->setProperty("sourceColor", QColor("yellow"));
- QCOMPARE(rect->color(),QColor("yellow"));
-
- rect->setState("green");
- QCOMPARE(rect->color(),QColor("green"));
- rect->setProperty("sourceColor", QColor("purple"));
- QCOMPARE(rect->color(),QColor("green"));
-
- rect->setState("blue");
- QCOMPARE(rect->color(),QColor("purple"));
-
- rect->setState("green");
- QCOMPARE(rect->color(),QColor("green"));
-
- rect->setState("");
- QCOMPARE(rect->color(),QColor("red"));
- }
-}
-
-class MyRect : public QmlGraphicsRectangle
-{
- Q_OBJECT
-public:
- MyRect() {}
- void doSomething() { emit didSomething(); }
-Q_SIGNALS:
- void didSomething();
-};
-
-QML_DECLARE_TYPE(MyRect)
-QML_DEFINE_TYPE(Qt.test, 1, 0, MyRectangle,MyRect);
-
-void tst_qmlstates::signalOverride()
-{
- QmlEngine engine;
-
- {
- QmlComponent rectComponent(&engine, SRCDIR "/data/signalOverride.qml");
- MyRect *rect = qobject_cast<MyRect*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QCOMPARE(rect->color(),QColor("red"));
- rect->doSomething();
- QCOMPARE(rect->color(),QColor("blue"));
-
- rect->setState("green");
- rect->doSomething();
- QCOMPARE(rect->color(),QColor("green"));
- }
-
- {
- QmlComponent rectComponent(&engine, SRCDIR "/data/signalOverride2.qml");
- MyRect *rect = qobject_cast<MyRect*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QCOMPARE(rect->color(),QColor("white"));
- rect->doSomething();
- QCOMPARE(rect->color(),QColor("blue"));
-
- QmlGraphicsRectangle *innerRect = qobject_cast<QmlGraphicsRectangle*>(rect->findChild<QmlGraphicsRectangle*>("extendedRect"));
-
- 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_qmlstates::signalOverrideCrash()
-{
- QmlEngine engine;
-
- QmlComponent rectComponent(&engine, SRCDIR "/data/signalOverrideCrash.qml");
- MyRect *rect = qobject_cast<MyRect*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- rect->setState("overridden");
- rect->doSomething();
-}
-
-void tst_qmlstates::parentChange()
-{
- QmlEngine engine;
-
- {
- QmlComponent rectComponent(&engine, SRCDIR "/data/parentChange.qml");
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QmlGraphicsRectangle *innerRect = qobject_cast<QmlGraphicsRectangle*>(rect->findChild<QmlGraphicsRectangle*>("MyRect"));
- QVERIFY(innerRect != 0);
-
- QmlListReference list(rect, "states");
- QmlState *state = qobject_cast<QmlState*>(list.at(0));
- QVERIFY(state != 0);
-
- qmlExecuteDeferred(state);
- QmlParentChange *pChange = qobject_cast<QmlParentChange*>(state->operationAt(0));
- QVERIFY(pChange != 0);
- QmlGraphicsItem *nParent = qobject_cast<QmlGraphicsItem*>(rect->findChild<QmlGraphicsItem*>("NewParent"));
- QVERIFY(nParent != 0);
-
- QCOMPARE(pChange->parent(), nParent);
-
- rect->setState("reparented");
- QCOMPARE(innerRect->rotation(), qreal(0));
- QCOMPARE(innerRect->scale(), qreal(1));
- QCOMPARE(innerRect->x(), qreal(-133));
- QCOMPARE(innerRect->y(), qreal(-300));
- }
-
- {
- QmlComponent rectComponent(&engine, SRCDIR "/data/parentChange2.qml");
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QmlGraphicsRectangle *innerRect = qobject_cast<QmlGraphicsRectangle*>(rect->findChild<QmlGraphicsRectangle*>("MyRect"));
- QVERIFY(innerRect != 0);
-
- rect->setState("reparented");
- QCOMPARE(innerRect->rotation(), qreal(15));
- QCOMPARE(innerRect->scale(), qreal(.5));
- QEXPECT_FAIL("", "QTBUG-2919", Continue);
- QCOMPARE(QString("%1").arg(innerRect->x()), QString("%1").arg(12.4148145657));
- QEXPECT_FAIL("", "QTBUG-2919", Continue);
- QCOMPARE(QString("%1").arg(innerRect->y()), QString("%1").arg(10.6470476128));
- }
-
- {
- QmlComponent rectComponent(&engine, SRCDIR "/data/parentChange3.qml");
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QmlGraphicsRectangle *innerRect = qobject_cast<QmlGraphicsRectangle*>(rect->findChild<QmlGraphicsRectangle*>("MyRect"));
- QVERIFY(innerRect != 0);
-
- rect->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));
-
- rect->setState("");
- QCOMPARE(innerRect->rotation(), qreal(0));
- QCOMPARE(innerRect->scale(), qreal(1));
- QCOMPARE(innerRect->x(), qreal(5));
- QEXPECT_FAIL("", "QTBUG-2919", Continue);
- QCOMPARE(innerRect->y(), qreal(0));
- }
-}
-
-void tst_qmlstates::parentChangeErrors()
-{
- QmlEngine engine;
-
- {
- QmlComponent rectComponent(&engine, SRCDIR "/data/parentChange4.qml");
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QmlGraphicsRectangle *innerRect = qobject_cast<QmlGraphicsRectangle*>(rect->findChild<QmlGraphicsRectangle*>("MyRect"));
- QVERIFY(innerRect != 0);
-
- QTest::ignoreMessage(QtWarningMsg, QByteArray("QML ParentChange (" + fullDataPath("/data/parentChange4.qml") + ":25:9) Unable to preserve appearance under non-uniform scale").constData());
- rect->setState("reparented");
- QCOMPARE(innerRect->rotation(), qreal(0));
- QCOMPARE(innerRect->scale(), qreal(1));
- QCOMPARE(innerRect->x(), qreal(5));
- QCOMPARE(innerRect->y(), qreal(5));
- }
-
- {
- QmlComponent rectComponent(&engine, SRCDIR "/data/parentChange5.qml");
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QmlGraphicsRectangle *innerRect = qobject_cast<QmlGraphicsRectangle*>(rect->findChild<QmlGraphicsRectangle*>("MyRect"));
- QVERIFY(innerRect != 0);
-
- QTest::ignoreMessage(QtWarningMsg, QByteArray("QML ParentChange (" + fullDataPath("/data/parentChange5.qml") + ":25:9) Unable to preserve appearance under complex transform").constData());
- 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_qmlstates::anchorChanges()
-{
- QmlEngine engine;
-
- QmlComponent rectComponent(&engine, SRCDIR "/data/anchorChanges.qml");
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QmlGraphicsRectangle *innerRect = qobject_cast<QmlGraphicsRectangle*>(rect->findChild<QmlGraphicsRectangle*>("MyRect"));
- QVERIFY(innerRect != 0);
-
- QmlListReference list(rect, "states");
- QmlState *state = qobject_cast<QmlState*>(list.at(0));
- QVERIFY(state != 0);
-
- qmlExecuteDeferred(state);
- QmlAnchorChanges *aChanges = qobject_cast<QmlAnchorChanges*>(state->operationAt(0));
- QVERIFY(aChanges != 0);
-
- rect->setState("right");
- QCOMPARE(innerRect->x(), qreal(150));
- QCOMPARE(aChanges->reset(), QString("left"));
- QCOMPARE(aChanges->object(), innerRect);
- QCOMPARE(aChanges->right().item, rect->right().item);
- QCOMPARE(aChanges->right().anchorLine, rect->right().anchorLine);
-
- rect->setState("");
- QCOMPARE(innerRect->x(), qreal(5));
-
- delete rect;
-}
-
-void tst_qmlstates::anchorChanges2()
-{
- QmlEngine engine;
-
- QmlComponent rectComponent(&engine, SRCDIR "/data/anchorChanges2.qml");
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QmlGraphicsRectangle *innerRect = qobject_cast<QmlGraphicsRectangle*>(rect->findChild<QmlGraphicsRectangle*>("MyRect"));
- QVERIFY(innerRect != 0);
-
- rect->setState("right");
- QEXPECT_FAIL("", "QTBUG-5338", Continue);
- QCOMPARE(innerRect->x(), qreal(150));
-
- rect->setState("");
- QCOMPARE(innerRect->x(), qreal(5));
-
- delete rect;
-}
-
-void tst_qmlstates::anchorChanges3()
-{
- QmlEngine engine;
-
- QmlComponent rectComponent(&engine, SRCDIR "/data/anchorChanges3.qml");
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QmlGraphicsRectangle *innerRect = qobject_cast<QmlGraphicsRectangle*>(rect->findChild<QmlGraphicsRectangle*>("MyRect"));
- QVERIFY(innerRect != 0);
-
- QmlGraphicsItem *leftGuideline = qobject_cast<QmlGraphicsItem*>(rect->findChild<QmlGraphicsItem*>("LeftGuideline"));
- QVERIFY(leftGuideline != 0);
-
- QmlGraphicsItem *bottomGuideline = qobject_cast<QmlGraphicsItem*>(rect->findChild<QmlGraphicsItem*>("BottomGuideline"));
- QVERIFY(bottomGuideline != 0);
-
- QmlListReference list(rect, "states");
- QmlState *state = qobject_cast<QmlState*>(list.at(0));
- QVERIFY(state != 0);
-
- qmlExecuteDeferred(state);
- QmlAnchorChanges *aChanges = qobject_cast<QmlAnchorChanges*>(state->operationAt(0));
- QVERIFY(aChanges != 0);
-
- rect->setState("reanchored");
- QCOMPARE(aChanges->object(), innerRect);
- QCOMPARE(aChanges->left().item, leftGuideline->left().item);
- QCOMPARE(aChanges->left().anchorLine, leftGuideline->left().anchorLine);
- QCOMPARE(aChanges->right().item, rect->right().item);
- QCOMPARE(aChanges->right().anchorLine, rect->right().anchorLine);
- QCOMPARE(aChanges->top().item, rect->top().item);
- QCOMPARE(aChanges->top().anchorLine, rect->top().anchorLine);
- QCOMPARE(aChanges->bottom().item, bottomGuideline->bottom().item);
- QCOMPARE(aChanges->bottom().anchorLine, bottomGuideline->bottom().anchorLine);
-
- QCOMPARE(innerRect->x(), qreal(10));
- QCOMPARE(innerRect->y(), qreal(0));
- QCOMPARE(innerRect->width(), qreal(190));
- QCOMPARE(innerRect->height(), qreal(150));
-
- rect->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_qmlstates::anchorChanges4()
-{
- QmlEngine engine;
-
- QmlComponent rectComponent(&engine, SRCDIR "/data/anchorChanges4.qml");
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QmlGraphicsRectangle *innerRect = qobject_cast<QmlGraphicsRectangle*>(rect->findChild<QmlGraphicsRectangle*>("MyRect"));
- QVERIFY(innerRect != 0);
-
- QmlGraphicsItem *leftGuideline = qobject_cast<QmlGraphicsItem*>(rect->findChild<QmlGraphicsItem*>("LeftGuideline"));
- QVERIFY(leftGuideline != 0);
-
- QmlGraphicsItem *bottomGuideline = qobject_cast<QmlGraphicsItem*>(rect->findChild<QmlGraphicsItem*>("BottomGuideline"));
- QVERIFY(bottomGuideline != 0);
-
- QmlListReference list(rect, "states");
- QmlState *state = qobject_cast<QmlState*>(list.at(0));
- QVERIFY(state != 0);
-
- qmlExecuteDeferred(state);
- QmlAnchorChanges *aChanges = qobject_cast<QmlAnchorChanges*>(state->operationAt(0));
- QVERIFY(aChanges != 0);
-
- rect->setState("reanchored");
- QCOMPARE(aChanges->object(), innerRect);
- QCOMPARE(aChanges->horizontalCenter().item, bottomGuideline->horizontalCenter().item);
- QCOMPARE(aChanges->horizontalCenter().anchorLine, bottomGuideline->horizontalCenter().anchorLine);
- QCOMPARE(aChanges->verticalCenter().item, leftGuideline->verticalCenter().item);
- QCOMPARE(aChanges->verticalCenter().anchorLine, leftGuideline->verticalCenter().anchorLine);
-
- delete rect;
-}
-
-void tst_qmlstates::anchorChanges5()
-{
- QmlEngine engine;
-
- QmlComponent rectComponent(&engine, SRCDIR "/data/anchorChanges5.qml");
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QmlGraphicsRectangle *innerRect = qobject_cast<QmlGraphicsRectangle*>(rect->findChild<QmlGraphicsRectangle*>("MyRect"));
- QVERIFY(innerRect != 0);
-
- QmlGraphicsItem *leftGuideline = qobject_cast<QmlGraphicsItem*>(rect->findChild<QmlGraphicsItem*>("LeftGuideline"));
- QVERIFY(leftGuideline != 0);
-
- QmlGraphicsItem *bottomGuideline = qobject_cast<QmlGraphicsItem*>(rect->findChild<QmlGraphicsItem*>("BottomGuideline"));
- QVERIFY(bottomGuideline != 0);
-
- QmlListReference list(rect, "states");
- QmlState *state = qobject_cast<QmlState*>(list.at(0));
- QVERIFY(state != 0);
-
- qmlExecuteDeferred(state);
- QmlAnchorChanges *aChanges = qobject_cast<QmlAnchorChanges*>(state->operationAt(0));
- QVERIFY(aChanges != 0);
-
- rect->setState("reanchored");
- QCOMPARE(aChanges->object(), innerRect);
- QCOMPARE(aChanges->horizontalCenter().item, bottomGuideline->horizontalCenter().item);
- QCOMPARE(aChanges->horizontalCenter().anchorLine, bottomGuideline->horizontalCenter().anchorLine);
- QCOMPARE(aChanges->baseline().item, leftGuideline->baseline().item);
- QCOMPARE(aChanges->baseline().anchorLine, leftGuideline->baseline().anchorLine);
-
- delete rect;
-}
-
-void tst_qmlstates::script()
-{
- QmlEngine engine;
-
- {
- QmlComponent rectComponent(&engine, SRCDIR "/data/script.qml");
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QCOMPARE(rect->color(),QColor("red"));
-
- rect->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
-
- rect->setState("");
- QCOMPARE(rect->color(),QColor("blue")); // a script isn't reverted
- }
-}
-
-void tst_qmlstates::restoreEntryValues()
-{
- QmlEngine engine;
-
- QmlComponent rectComponent(&engine, SRCDIR "/data/restoreEntryValues.qml");
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QCOMPARE(rect->color(),QColor("red"));
-
- rect->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
-
- rect->setState("");
- QCOMPARE(rect->color(),QColor("blue"));
-}
-
-void tst_qmlstates::explicitChanges()
-{
- QmlEngine engine;
-
- QmlComponent rectComponent(&engine, SRCDIR "/data/explicit.qml");
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QmlListReference list(rect, "states");
- QmlState *state = qobject_cast<QmlState*>(list.at(0));
- QVERIFY(state != 0);
-
- qmlExecuteDeferred(state);
- QmlPropertyChanges *changes = qobject_cast<QmlPropertyChanges*>(rect->findChild<QmlPropertyChanges*>("changes"));
- QVERIFY(changes != 0);
- QVERIFY(changes->isExplicit());
-
- QCOMPARE(rect->color(),QColor("red"));
-
- rect->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
-
- rect->setProperty("sourceColor", QColor("green"));
- QCOMPARE(rect->color(),QColor("blue"));
-
- rect->setState("");
- QCOMPARE(rect->color(),QColor("red"));
- rect->setProperty("sourceColor", QColor("yellow"));
- QCOMPARE(rect->color(),QColor("red"));
-
- rect->setState("blue");
- QCOMPARE(rect->color(),QColor("yellow"));
-}
-
-void tst_qmlstates::propertyErrors()
-{
- QmlEngine engine;
- QmlComponent rectComponent(&engine, SRCDIR "/data/propertyErrors.qml");
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QCOMPARE(rect->color(),QColor("red"));
-
- QTest::ignoreMessage(QtWarningMsg, QByteArray("QML PropertyChanges (" + fullDataPath("/data/propertyErrors.qml") + ":8:9) Cannot assign to non-existent property \"colr\"").constData());
- QTest::ignoreMessage(QtWarningMsg, QByteArray("QML PropertyChanges (" + fullDataPath("/data/propertyErrors.qml") + ":8:9) Cannot assign to read-only property \"wantsFocus\"").constData());
- rect->setState("blue");
-}
-
-void tst_qmlstates::incorrectRestoreBug()
-{
- QmlEngine engine;
-
- QmlComponent rectComponent(&engine, SRCDIR "/data/basicChanges.qml");
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QCOMPARE(rect->color(),QColor("red"));
-
- rect->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
-
- rect->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"));
-
- rect->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
-
- rect->setState("");
- QCOMPARE(rect->color(),QColor("green"));
-}
-
-void tst_qmlstates::autoStateAtStartupRestoreBug()
-{
- QmlEngine engine;
-
- QmlComponent component(&engine, SRCDIR "/data/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_qmlstates::deletingChange()
-{
- QmlEngine engine;
-
- QmlComponent rectComponent(&engine, SRCDIR "/data/deleting.qml");
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- rect->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
- QCOMPARE(rect->radius(),qreal(5));
-
- rect->setState("");
- QCOMPARE(rect->color(),QColor("red"));
- QCOMPARE(rect->radius(),qreal(0));
-
- QmlPropertyChanges *pc = rect->findChild<QmlPropertyChanges*>("pc1");
- QVERIFY(pc != 0);
- delete pc;
-
- QmlState *state = rect->findChild<QmlState*>();
- QVERIFY(state != 0);
- qmlExecuteDeferred(state);
- QCOMPARE(state->operationCount(), 1);
-
- rect->setState("blue");
- QCOMPARE(rect->color(),QColor("red"));
- QCOMPARE(rect->radius(),qreal(5));
-
- delete rect;
-}
-
-void tst_qmlstates::deletingState()
-{
- QmlEngine engine;
-
- QmlComponent rectComponent(&engine, SRCDIR "/data/deletingState.qml");
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QmlStateGroup *sg = rect->findChild<QmlStateGroup*>();
- QVERIFY(sg != 0);
- QVERIFY(sg->findState("blue") != 0);
-
- sg->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
-
- sg->setState("");
- QCOMPARE(rect->color(),QColor("red"));
-
- QmlState *state = rect->findChild<QmlState*>();
- 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_qmlstates::tempState()
-{
- QmlEngine engine;
-
- QmlComponent rectComponent(&engine, SRCDIR "/data/legalTempState.qml");
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QTest::ignoreMessage(QtDebugMsg, "entering placed");
- QTest::ignoreMessage(QtDebugMsg, "entering idle");
- rect->setState("placed");
- QCOMPARE(rect->state(), QLatin1String("idle"));
-}
-
-void tst_qmlstates::illegalTempState()
-{
- QmlEngine engine;
-
- QmlComponent rectComponent(&engine, SRCDIR "/data/illegalTempState.qml");
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QTest::ignoreMessage(QtWarningMsg, "Can't apply a state change as part of a state definition. ");
- rect->setState("placed");
- QCOMPARE(rect->state(), QLatin1String("placed"));
-}
-
-void tst_qmlstates::nonExistantProperty()
-{
- QmlEngine engine;
-
- QmlComponent rectComponent(&engine, SRCDIR "/data/nonExistantProp.qml");
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QTest::ignoreMessage(QtWarningMsg, QByteArray("QML PropertyChanges (" + fullDataPath("/data/nonExistantProp.qml") + ":9:9) Cannot assign to non-existent property \"colr\"").constData());
- rect->setState("blue");
- QCOMPARE(rect->state(), QLatin1String("blue"));
-}
-
-QTEST_MAIN(tst_qmlstates)
-
-#include "tst_qmlstates.moc"
diff --git a/tests/auto/declarative/qmlsystempalette/qmlsystempalette.pro b/tests/auto/declarative/qmlsystempalette/qmlsystempalette.pro
deleted file mode 100644
index 4d55b46..0000000
--- a/tests/auto/declarative/qmlsystempalette/qmlsystempalette.pro
+++ /dev/null
@@ -1,5 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative gui
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qmlsystempalette.cpp
diff --git a/tests/auto/declarative/qmlsystempalette/tst_qmlsystempalette.cpp b/tests/auto/declarative/qmlsystempalette/tst_qmlsystempalette.cpp
deleted file mode 100644
index 06e4d1c..0000000
--- a/tests/auto/declarative/qmlsystempalette/tst_qmlsystempalette.cpp
+++ /dev/null
@@ -1,187 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qtest.h>
-#include <QDebug>
-#include <QtDeclarative/qmlengine.h>
-#include <QtDeclarative/qmlcomponent.h>
-#include <private/qmlsystempalette_p.h>
-#include <qpalette.h>
-#include "../../../shared/util.h"
-
-class tst_qmlsystempalette : public QObject
-
-{
- Q_OBJECT
-public:
- tst_qmlsystempalette();
-
-private slots:
- void activePalette();
- void inactivePalette();
- void disabledPalette();
- void paletteChanged();
-
-private:
- QmlEngine engine;
-};
-
-tst_qmlsystempalette::tst_qmlsystempalette()
-{
-}
-
-void tst_qmlsystempalette::activePalette()
-{
- QString componentStr = "import Qt 4.6\nSystemPalette { }";
- QmlComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlSystemPalette *object = qobject_cast<QmlSystemPalette*>(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_qmlsystempalette::inactivePalette()
-{
- QString componentStr = "import Qt 4.6\nSystemPalette { colorGroup: SystemPalette.Inactive }";
- QmlComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlSystemPalette *object = qobject_cast<QmlSystemPalette*>(component.create());
-
- QVERIFY(object != 0);
- QVERIFY(object->colorGroup() == QmlSystemPalette::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_qmlsystempalette::disabledPalette()
-{
- QString componentStr = "import Qt 4.6\nSystemPalette { colorGroup: SystemPalette.Disabled }";
- QmlComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlSystemPalette *object = qobject_cast<QmlSystemPalette*>(component.create());
-
- QVERIFY(object != 0);
- QVERIFY(object->colorGroup() == QmlSystemPalette::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_qmlsystempalette::paletteChanged()
-{
- QString componentStr = "import Qt 4.6\nSystemPalette { }";
- QmlComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlSystemPalette *object = qobject_cast<QmlSystemPalette*>(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(QmlSystemPalette::Active);
- QTRY_COMPARE(QColor("red"), object->text());
- QTRY_COMPARE(QColor("green"), object->buttonText());
- QTRY_COMPARE(QColor("blue"), object->windowText());
-
- delete object;
-}
-
-QTEST_MAIN(tst_qmlsystempalette)
-
-#include "tst_qmlsystempalette.moc"
diff --git a/tests/auto/declarative/qmltimer/qmltimer.pro b/tests/auto/declarative/qmltimer/qmltimer.pro
deleted file mode 100644
index 2b244ed..0000000
--- a/tests/auto/declarative/qmltimer/qmltimer.pro
+++ /dev/null
@@ -1,7 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative gui
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qmltimer.cpp
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmltimer/tst_qmltimer.cpp b/tests/auto/declarative/qmltimer/tst_qmltimer.cpp
deleted file mode 100644
index b8b5e62..0000000
--- a/tests/auto/declarative/qmltimer/tst_qmltimer.cpp
+++ /dev/null
@@ -1,285 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtDeclarative/qmlengine.h>
-#include <QtDeclarative/qmlcomponent.h>
-#include <private/qmltimer_p.h>
-#include <QDebug>
-
-class tst_qmltimer : public QObject
-{
- Q_OBJECT
-public:
- tst_qmltimer();
-
-private slots:
- void notRepeating();
- void notRepeatingStart();
- void repeat();
- void noTriggerIfNotRunning();
- void triggeredOnStart();
- void triggeredOnStartRepeat();
- void changeDuration();
- void restart();
-};
-
-class TimerHelper : public QObject
-{
- Q_OBJECT
-public:
- TimerHelper() : QObject(), count(0)
- {
- }
-
- int count;
-
-public slots:
- void timeout() {
- ++count;
- }
-};
-
-#if defined(Q_OS_SYMBIAN) && defined(Q_CC_NOKIAX86)
-// Increase wait as emulator startup can cause unexpected delays
-#define TIMEOUT_TIMEOUT 2000
-#else
-#define TIMEOUT_TIMEOUT 200
-#endif
-
-tst_qmltimer::tst_qmltimer()
-{
-}
-
-void tst_qmltimer::notRepeating()
-{
- QmlEngine engine;
- QmlComponent component(&engine);
- component.setData(QByteArray("import Qt 4.6\nTimer { interval: 100; running: true }"), QUrl::fromLocalFile(""));
- QmlTimer *timer = qobject_cast<QmlTimer*>(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_qmltimer::notRepeatingStart()
-{
- QmlEngine engine;
- QmlComponent component(&engine);
- component.setData(QByteArray("import Qt 4.6\nTimer { interval: 100 }"), QUrl::fromLocalFile(""));
- QmlTimer *timer = qobject_cast<QmlTimer*>(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_qmltimer::repeat()
-{
- QmlEngine engine;
- QmlComponent component(&engine);
- component.setData(QByteArray("import Qt 4.6\nTimer { interval: 100; repeat: true; running: true }"), QUrl::fromLocalFile(""));
- QmlTimer *timer = qobject_cast<QmlTimer*>(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);
-
- delete timer;
-}
-
-void tst_qmltimer::triggeredOnStart()
-{
- QmlEngine engine;
- QmlComponent component(&engine);
- component.setData(QByteArray("import Qt 4.6\nTimer { interval: 100; running: true; triggeredOnStart: true }"), QUrl::fromLocalFile(""));
- QmlTimer *timer = qobject_cast<QmlTimer*>(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);
-
- delete timer;
-}
-
-void tst_qmltimer::triggeredOnStartRepeat()
-{
- QmlEngine engine;
- QmlComponent component(&engine);
- component.setData(QByteArray("import Qt 4.6\nTimer { interval: 100; running: true; triggeredOnStart: true; repeat: true }"), QUrl::fromLocalFile(""));
- QmlTimer *timer = qobject_cast<QmlTimer*>(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_qmltimer::noTriggerIfNotRunning()
-{
- QmlEngine engine;
- QmlComponent component(&engine);
- component.setData(QByteArray(
- "import Qt 4.6\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_qmltimer::changeDuration()
-{
- QmlEngine engine;
- QmlComponent component(&engine);
- component.setData(QByteArray("import Qt 4.6\nTimer { interval: 200; repeat: true; running: true }"), QUrl::fromLocalFile(""));
- QmlTimer *timer = qobject_cast<QmlTimer*>(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());
-
- delete timer;
-}
-
-void tst_qmltimer::restart()
-{
- QmlEngine engine;
- QmlComponent component(&engine);
- component.setData(QByteArray("import Qt 4.6\nTimer { interval: 500; repeat: true; running: true }"), QUrl::fromLocalFile(""));
- QmlTimer *timer = qobject_cast<QmlTimer*>(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;
-}
-
-QTEST_MAIN(tst_qmltimer)
-
-#include "tst_qmltimer.moc"
diff --git a/tests/auto/declarative/qmlvaluetypes/qmlvaluetypes.pro b/tests/auto/declarative/qmlvaluetypes/qmlvaluetypes.pro
deleted file mode 100644
index 82d067e..0000000
--- a/tests/auto/declarative/qmlvaluetypes/qmlvaluetypes.pro
+++ /dev/null
@@ -1,10 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative
-macx:CONFIG -= app_bundle
-
-HEADERS += testtypes.h
-
-SOURCES += tst_qmlvaluetypes.cpp \
- testtypes.cpp
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmlvaluetypes/testtypes.cpp b/tests/auto/declarative/qmlvaluetypes/testtypes.cpp
deleted file mode 100644
index c51b777..0000000
--- a/tests/auto/declarative/qmlvaluetypes/testtypes.cpp
+++ /dev/null
@@ -1,45 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include "testtypes.h"
-
-QML_DEFINE_TYPE(Test, 1, 0, MyTypeObject, MyTypeObject);
-QML_DEFINE_TYPE(Test, 1, 0, MyConstantValueSource, MyConstantValueSource);
-QML_DEFINE_TYPE(Test, 1, 0, MyOffsetValueInterceptor, MyOffsetValueInterceptor);
diff --git a/tests/auto/declarative/qmlvaluetypes/testtypes.h b/tests/auto/declarative/qmlvaluetypes/testtypes.h
deleted file mode 100644
index b57fbff..0000000
--- a/tests/auto/declarative/qmlvaluetypes/testtypes.h
+++ /dev/null
@@ -1,152 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef TESTTYPES_H
-#define TESTTYPES_H
-
-#include <QObject>
-#include <QPoint>
-#include <QPointF>
-#include <QSize>
-#include <QSizeF>
-#include <QRect>
-#include <QRectF>
-#include <QVector3D>
-#include <QFont>
-#include <qml.h>
-#include <QmlPropertyValueSource>
-
-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(QSize size READ size WRITE setSize NOTIFY changed);
- Q_PROPERTY(QSizeF sizef READ sizef WRITE setSizef NOTIFY changed);
- Q_PROPERTY(QRect rect READ rect WRITE setRect NOTIFY changed);
- Q_PROPERTY(QRectF rectf READ rectf WRITE setRectf NOTIFY changed);
- Q_PROPERTY(QVector3D vector READ vector WRITE setVector NOTIFY changed);
- Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY changed);
-
-public:
- MyTypeObject() :
- m_point(10, 4),
- m_pointf(11.3, -10.9),
- m_size(1912, 1913),
- m_sizef(0.1, 100923.2),
- m_rect(2, 3, 109, 102),
- m_rectf(103.8, 99.2, 88.1, 77.6),
- m_vector(23.88, 3.1, 4.3)
- {
- 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::AllUppercase);
- m_font.setLetterSpacing(QFont::AbsoluteSpacing, 10.2);
- m_font.setWordSpacing(19.7);
- }
-
- 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(); }
-
- 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(); }
-
- 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(); }
-
- QVector3D m_vector;
- QVector3D vector() const { return m_vector; }
- void setVector(const QVector3D &v) { m_vector = v; emit changed(); }
-
- QFont m_font;
- QFont font() const { return m_font; }
- void setFont(const QFont &v) { m_font = v; emit changed(); }
-
- void emitRunScript() { emit runScript(); }
-
-signals:
- void changed();
- void runScript();
-};
-QML_DECLARE_TYPE(MyTypeObject);
-
-class MyConstantValueSource : public QObject, public QmlPropertyValueSource
-{
- Q_OBJECT
-public:
- virtual void setTarget(const QmlMetaProperty &p) { p.write(3345); }
-};
-QML_DECLARE_TYPE(MyConstantValueSource);
-
-class MyOffsetValueInterceptor : public QObject, public QmlPropertyValueInterceptor
-{
- Q_OBJECT
-public:
- virtual void setTarget(const QmlMetaProperty &p) { prop = p; }
- virtual void write(const QVariant &value) { prop.write(value.toInt() + 13, QmlMetaProperty::BypassInterceptor); }
-
-private:
- QmlMetaProperty prop;
-};
-QML_DECLARE_TYPE(MyOffsetValueInterceptor);
-
-#endif // TESTTYPES_H
diff --git a/tests/auto/declarative/qmlvaluetypes/tst_qmlvaluetypes.cpp b/tests/auto/declarative/qmlvaluetypes/tst_qmlvaluetypes.cpp
deleted file mode 100644
index f99d3ce..0000000
--- a/tests/auto/declarative/qmlvaluetypes/tst_qmlvaluetypes.cpp
+++ /dev/null
@@ -1,588 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qtest.h>
-#include <QmlEngine>
-#include <QmlComponent>
-#include <QDebug>
-#include <private/qmlvaluetype_p.h>
-#include "testtypes.h"
-
-class tst_qmlvaluetypes : public QObject
-{
- Q_OBJECT
-public:
- tst_qmlvaluetypes() {}
-
-private slots:
- void point();
- void pointf();
- void size();
- void sizef();
- void rect();
- void rectf();
- void vector3d();
- void font();
-
- void bindingAssignment();
- void bindingRead();
- void staticAssignment();
- void scriptAccess();
- void autoBindingRemoval();
- void valueSources();
- void valueInterceptors();
- void bindingConflict();
- void deletedObject();
- void bindingVariantCopy();
- void scriptVariantCopy();
- void cppClasses();
-
-private:
- QmlEngine engine;
-};
-
-inline QUrl TEST_FILE(const QString &filename)
-{
- return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename);
-}
-
-void tst_qmlvaluetypes::point()
-{
- {
- QmlComponent component(&engine, TEST_FILE("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;
- }
-
- {
- QmlComponent component(&engine, TEST_FILE("point_write.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->point(), QPoint(11, 12));
-
- delete object;
- }
-}
-
-void tst_qmlvaluetypes::pointf()
-{
- {
- QmlComponent component(&engine, TEST_FILE("pointf_read.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("p_x").toDouble(), 11.3);
- QCOMPARE(object->property("p_y").toDouble(), -10.9);
- QCOMPARE(object->property("copy"), QVariant(QPointF(11.3, -10.9)));
-
- delete object;
- }
-
- {
- QmlComponent component(&engine, TEST_FILE("pointf_write.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->pointf(), QPointF(6.8, 9.3));
-
- delete object;
- }
-}
-
-void tst_qmlvaluetypes::size()
-{
- {
- QmlComponent component(&engine, TEST_FILE("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;
- }
-
- {
- QmlComponent component(&engine, TEST_FILE("size_write.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->size(), QSize(13, 88));
-
- delete object;
- }
-}
-
-void tst_qmlvaluetypes::sizef()
-{
- {
- QmlComponent component(&engine, TEST_FILE("sizef_read.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("s_width").toDouble(), 0.1);
- QCOMPARE(object->property("s_height").toDouble(), 100923.2);
- QCOMPARE(object->property("copy"), QVariant(QSizeF(0.1, 100923.2)));
-
- delete object;
- }
-
- {
- QmlComponent component(&engine, TEST_FILE("sizef_write.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->sizef(), QSizeF(44.3, 92.8));
-
- delete object;
- }
-}
-
-void tst_qmlvaluetypes::rect()
-{
- {
- QmlComponent component(&engine, TEST_FILE("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;
- }
-
- {
- QmlComponent component(&engine, TEST_FILE("rect_write.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->rect(), QRect(1234, 7, 56, 63));
-
- delete object;
- }
-}
-
-void tst_qmlvaluetypes::rectf()
-{
- {
- QmlComponent component(&engine, TEST_FILE("rectf_read.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("r_x").toDouble(), 103.8);
- QCOMPARE(object->property("r_y").toDouble(), 99.2);
- QCOMPARE(object->property("r_width").toDouble(), 88.1);
- QCOMPARE(object->property("r_height").toDouble(), 77.6);
- QCOMPARE(object->property("copy"), QVariant(QRectF(103.8, 99.2, 88.1, 77.6)));
-
- delete object;
- }
-
- {
- QmlComponent component(&engine, TEST_FILE("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;
- }
-}
-
-void tst_qmlvaluetypes::vector3d()
-{
- {
- QmlComponent component(&engine, TEST_FILE("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;
- }
-
- {
- QmlComponent component(&engine, TEST_FILE("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;
- }
-}
-
-void tst_qmlvaluetypes::font()
-{
- {
- QmlComponent component(&engine, TEST_FILE("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(), object->font().pixelSize());
- 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;
- }
-
- {
- QmlComponent component(&engine, TEST_FILE("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);
-
- QEXPECT_FAIL("", "QT-2920", Continue);
- QCOMPARE(object->font(), font);
-
- delete object;
- }
-
- // Test pixelSize
- {
- QmlComponent component(&engine, TEST_FILE("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
- {
- QmlComponent component(&engine, TEST_FILE("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;
- }
-}
-
-// Test bindings can write to value types
-void tst_qmlvaluetypes::bindingAssignment()
-{
- QmlComponent component(&engine, TEST_FILE("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_qmlvaluetypes::bindingRead()
-{
- QmlComponent component(&engine, TEST_FILE("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_qmlvaluetypes::staticAssignment()
-{
- QmlComponent component(&engine, TEST_FILE("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_qmlvaluetypes::scriptAccess()
-{
- QmlComponent component(&engine, TEST_FILE("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_qmlvaluetypes::autoBindingRemoval()
-{
- {
- QmlComponent component(&engine, TEST_FILE("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));
-
- QEXPECT_FAIL("", "QT-2920", Continue);
- QCOMPARE(object->rect().x(), 42);
-
- delete object;
- }
-
- {
- QmlComponent component(&engine, TEST_FILE("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;
- }
-
- {
- QmlComponent component(&engine, TEST_FILE("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)));
-
- QEXPECT_FAIL("", "QT-2920", Continue);
- QCOMPARE(object->rect(), QRect(44, 22, 33, 44));
-
- delete object;
- }
-
-}
-
-// Test that property value sources assign to value types
-void tst_qmlvaluetypes::valueSources()
-{
- QmlComponent component(&engine, TEST_FILE("valueSources.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->rect().x(), 3345);
-
- delete object;
-}
-
-static void checkNoErrors(QmlComponent& component)
-{
- QList<QmlError> errors = component.errors();
- if (errors.isEmpty())
- return;
- for (int ii = 0; ii < errors.count(); ++ii) {
- const QmlError &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_qmlvaluetypes::valueInterceptors()
-{
- QmlComponent component(&engine, TEST_FILE("valueInterceptors.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- checkNoErrors(component);
- QEXPECT_FAIL("", "QT-2920", Abort);
- QVERIFY(object != 0);
-
- QCOMPARE(object->rect().x(), 26);
-
- 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_qmlvaluetypes::bindingConflict()
-{
- QmlComponent component(&engine, TEST_FILE("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_qmlvaluetypes::deletedObject()
-{
- QmlComponent component(&engine, TEST_FILE("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_qmlvaluetypes::bindingVariantCopy()
-{
- QmlComponent component(&engine, TEST_FILE("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_qmlvaluetypes::scriptVariantCopy()
-{
- QmlComponent component(&engine, TEST_FILE("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_qmlvaluetypes::cppClasses()
-{
- CPP_TEST(QmlPointValueType, QPoint(19, 33));
- CPP_TEST(QmlPointFValueType, QPointF(33.6, -23));
- CPP_TEST(QmlSizeValueType, QSize(-100, 18));
- CPP_TEST(QmlSizeFValueType, QSizeF(-100.7, 18.2));
- CPP_TEST(QmlRectValueType, QRect(13, 39, 10928, 88));
- CPP_TEST(QmlRectFValueType, QRectF(88.2, -90.1, 103.2, 118));
- CPP_TEST(QmlVector3DValueType, QVector3D(18.2, 19.7, 1002));
- CPP_TEST(QmlFontValueType, QFont("Helvetica"));
-
-}
-QTEST_MAIN(tst_qmlvaluetypes)
-
-#include "tst_qmlvaluetypes.moc"
diff --git a/tests/auto/declarative/qmlxmlhttprequest/qmlxmlhttprequest.pro b/tests/auto/declarative/qmlxmlhttprequest/qmlxmlhttprequest.pro
deleted file mode 100644
index ed87b2a..0000000
--- a/tests/auto/declarative/qmlxmlhttprequest/qmlxmlhttprequest.pro
+++ /dev/null
@@ -1,13 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative network
-macx:CONFIG -= app_bundle
-
-INCLUDEPATH += ../shared/
-HEADERS += ../shared/testhttpserver.h
-
-SOURCES += tst_qmlxmlhttprequest.cpp \
- ../shared/testhttpserver.cpp
-
-
-# Define SRCDIR equal to test's source directory
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmlxmlhttprequest/tst_qmlxmlhttprequest.cpp b/tests/auto/declarative/qmlxmlhttprequest/tst_qmlxmlhttprequest.cpp
deleted file mode 100644
index e675566..0000000
--- a/tests/auto/declarative/qmlxmlhttprequest/tst_qmlxmlhttprequest.cpp
+++ /dev/null
@@ -1,1315 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qtest.h>
-#include <QmlEngine>
-#include <QmlComponent>
-#include <QDebug>
-#include <QNetworkCookieJar>
-#include "testhttpserver.h"
-
-#define SERVER_PORT 14445
-
-class tst_qmlxmlhttprequest : public QObject
-{
- Q_OBJECT
-public:
- tst_qmlxmlhttprequest() {}
-
-private slots:
- void initTestCase() {
- if (QLocale::system().name().replace(QChar::fromAscii('_'),QChar::fromAscii('-')) != QLatin1String("en-US")) {
- qWarning() << "Test will fail unless LANG is en_US";
- }
- }
-
- void domExceptionCodes();
- void callbackException();
- void callbackException_data();
- void staticStateValues();
- void instanceStateValues();
- void constructor();
- void defaultState();
- void open();
- void open_invalid_method();
- void open_sync();
- void open_arg_count();
- void setRequestHeader();
- 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 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 statusText();
- void responseText();
- void responseXML_invalid();
- void invalidMethodUsage();
- void redirects();
-
- // Attributes
- void document();
- void element();
- void attr();
- void text();
- void cdata();
-
- // Crashes
- // void outstanding_request_at_shutdown();
-
- // void network_errors()
- // void readyState()
-
-private:
- QmlEngine engine;
-};
-
-inline QUrl TEST_FILE(const QString &filename)
-{
- return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename);
-}
-
-// Test that the dom exception codes are correct
-void tst_qmlxmlhttprequest::domExceptionCodes()
-{
- QmlComponent component(&engine, TEST_FILE("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;
-}
-
-#define TRY_WAIT(expr) \
- do { \
- for (int ii = 0; ii < 6; ++ii) { \
- if ((expr)) break; \
- QTest::qWait(50); \
- } \
- QVERIFY((expr)); \
- } while (false)
-
-
-void tst_qmlxmlhttprequest::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_qmlxmlhttprequest::callbackException()
-{
- // Test exception reporting for exceptions thrown at various points.
-
- QFETCH(QString, which);
- QFETCH(int, line);
-
- QString expect = TEST_FILE("callbackException.qml").toString() + ":"+QString::number(line)+": Error: Exception from Callback";
- QTest::ignoreMessage(QtWarningMsg, expect.toLatin1());
-
- QmlComponent component(&engine, TEST_FILE("callbackException.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "testdocument.html");
- object->setProperty("which", which);
- component.completeCreate();
-
- TRY_WAIT(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_qmlxmlhttprequest::staticStateValues()
-{
- QmlComponent component(&engine, TEST_FILE("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_qmlxmlhttprequest::instanceStateValues()
-{
- QmlComponent component(&engine, TEST_FILE("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_qmlxmlhttprequest::constructor()
-{
- QmlComponent component(&engine, TEST_FILE("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_qmlxmlhttprequest::defaultState()
-{
- QmlComponent component(&engine, TEST_FILE("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_qmlxmlhttprequest::open()
-{
- // Relative url
- {
- QmlComponent component(&engine, TEST_FILE("open.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);
-
- TRY_WAIT(object->property("dataOK").toBool() == true);
-
- delete object;
- }
-
- // Absolute url
- {
- QmlComponent component(&engine, TEST_FILE("open.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", TEST_FILE("testdocument.html").toString());
- 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);
-
- TRY_WAIT(object->property("dataOK").toBool() == true);
-
- delete object;
- }
-
- // Absolute network url
- {
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("open_network.expect"),
- TEST_FILE("open_network.reply"),
- TEST_FILE("testdocument.html")));
-
- QmlComponent component(&engine, TEST_FILE("open.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("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);
-
- TRY_WAIT(object->property("dataOK").toBool() == true);
-
- delete object;
- }
-
- // User/pass
- {
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("open_network.expect"),
- TEST_FILE("open_network.reply"),
- TEST_FILE("testdocument.html")));
-
- QmlComponent component(&engine, TEST_FILE("open_user.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("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);
-
- TRY_WAIT(object->property("dataOK").toBool() == true);
-
- // ### Check that the username/password were sent to the server
-
- delete object;
- }
-}
-
-// Test that calling XMLHttpRequest.open() with an invalid method raises an exception
-void tst_qmlxmlhttprequest::open_invalid_method()
-{
- QmlComponent component(&engine, TEST_FILE("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_qmlxmlhttprequest::open_sync()
-{
- QmlComponent component(&engine, TEST_FILE("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_qmlxmlhttprequest::open_arg_count()
-{
- {
- QmlComponent component(&engine, TEST_FILE("open_arg_count.1.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("exceptionThrown").toBool(), true);
-
- delete object;
- }
-
- {
- QmlComponent component(&engine, TEST_FILE("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_qmlxmlhttprequest::setRequestHeader()
-{
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("setRequestHeader.expect"),
- TEST_FILE("setRequestHeader.reply"),
- TEST_FILE("testdocument.html")));
-
- QmlComponent component(&engine, TEST_FILE("setRequestHeader.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
- component.completeCreate();
-
- TRY_WAIT(object->property("dataOK").toBool() == true);
-
- delete object;
-}
-
-// Test setting headers before open() throws exception
-void tst_qmlxmlhttprequest::setRequestHeader_unsent()
-{
- QmlComponent component(&engine, TEST_FILE("setRequestHeader_unsent.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toBool(), true);
-
- delete object;
-}
-
-void tst_qmlxmlhttprequest::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_qmlxmlhttprequest::setRequestHeader_illegalName()
-{
- QFETCH(QString, name);
-
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("open_network.expect"),
- TEST_FILE("open_network.reply"),
- TEST_FILE("testdocument.html")));
-
- QmlComponent component(&engine, TEST_FILE("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);
-
- TRY_WAIT(object->property("dataOK").toBool() == true);
-
- delete object;
-}
-
-// Test that attempting to set a header after a request is sent throws an exception
-void tst_qmlxmlhttprequest::setRequestHeader_sent()
-{
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("open_network.expect"),
- TEST_FILE("open_network.reply"),
- TEST_FILE("testdocument.html")));
-
- QmlComponent component(&engine, TEST_FILE("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);
-
- TRY_WAIT(object->property("dataOK").toBool() == true);
-
- delete object;
-}
-
-// Invalid arg count throws exception
-void tst_qmlxmlhttprequest::setRequestHeader_args()
-{
- QmlComponent component(&engine, TEST_FILE("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_qmlxmlhttprequest::send_unsent()
-{
- QmlComponent component(&engine, TEST_FILE("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_qmlxmlhttprequest::send_alreadySent()
-{
- QmlComponent component(&engine, TEST_FILE("send_alreadySent.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toBool(), true);
- TRY_WAIT(object->property("dataOK").toBool() == true);
-
- delete object;
-}
-
-// Test that send for a GET or HEAD ignores data
-void tst_qmlxmlhttprequest::send_ignoreData()
-{
- {
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("send_ignoreData_GET.expect"),
- TEST_FILE("send_ignoreData.reply"),
- TEST_FILE("testdocument.html")));
-
- QmlComponent component(&engine, TEST_FILE("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();
-
- TRY_WAIT(object->property("dataOK").toBool() == true);
-
- delete object;
- }
-
- {
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("send_ignoreData_PUT.expect"),
- TEST_FILE("send_ignoreData.reply"),
- TEST_FILE("testdocument.html")));
-
- QmlComponent component(&engine, TEST_FILE("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();
-
- TRY_WAIT(object->property("dataOK").toBool() == true);
-
- delete object;
- }
-}
-
-// Test that send()'ing data works
-void tst_qmlxmlhttprequest::send_withdata()
-{
- // No content-type
- {
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("send_data.1.expect"),
- TEST_FILE("send_data.reply"),
- TEST_FILE("testdocument.html")));
-
- QmlComponent component(&engine, TEST_FILE("send_data.1.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
- component.completeCreate();
-
- TRY_WAIT(object->property("dataOK").toBool() == true);
-
- delete object;
- }
-
- // Correct content-type
- {
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("send_data.1.expect"),
- TEST_FILE("send_data.reply"),
- TEST_FILE("testdocument.html")));
-
- QmlComponent component(&engine, TEST_FILE("send_data.2.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
- component.completeCreate();
-
- TRY_WAIT(object->property("dataOK").toBool() == true);
-
- delete object;
- }
-
- // Incorrect content-type
- {
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("send_data.1.expect"),
- TEST_FILE("send_data.reply"),
- TEST_FILE("testdocument.html")));
-
- QmlComponent component(&engine, TEST_FILE("send_data.3.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
- component.completeCreate();
-
- TRY_WAIT(object->property("dataOK").toBool() == true);
-
- delete object;
- }
-
- // Correct content-type - out of order
- {
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("send_data.4.expect"),
- TEST_FILE("send_data.reply"),
- TEST_FILE("testdocument.html")));
-
- QmlComponent component(&engine, TEST_FILE("send_data.4.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
- component.completeCreate();
-
- TRY_WAIT(object->property("dataOK").toBool() == true);
-
- delete object;
- }
-
- // Incorrect content-type - out of order
- {
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("send_data.4.expect"),
- TEST_FILE("send_data.reply"),
- TEST_FILE("testdocument.html")));
-
- QmlComponent component(&engine, TEST_FILE("send_data.5.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
- component.completeCreate();
-
- TRY_WAIT(object->property("dataOK").toBool() == true);
-
- delete object;
- }
-
- // PUT
- {
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("send_data.6.expect"),
- TEST_FILE("send_data.reply"),
- TEST_FILE("testdocument.html")));
-
- QmlComponent component(&engine, TEST_FILE("send_data.6.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
- component.completeCreate();
-
- TRY_WAIT(object->property("dataOK").toBool() == true);
-
- delete object;
- }
-
- // Correct content-type - no charset
- {
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("send_data.1.expect"),
- TEST_FILE("send_data.reply"),
- TEST_FILE("testdocument.html")));
-
- QmlComponent component(&engine, TEST_FILE("send_data.7.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
- component.completeCreate();
-
- TRY_WAIT(object->property("dataOK").toBool() == true);
-
- delete object;
- }
-}
-
-// Test abort() has no effect in unsent state
-void tst_qmlxmlhttprequest::abort_unsent()
-{
- QmlComponent component(&engine, TEST_FILE("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);
-
- TRY_WAIT(object->property("dataOK").toBool() == true);
-
- delete object;
-}
-
-// Test abort() cancels an open (but unsent) request
-void tst_qmlxmlhttprequest::abort_opened()
-{
- QmlComponent component(&engine, TEST_FILE("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);
-
- TRY_WAIT(object->property("dataOK").toBool() == true);
-
- delete object;
-}
-
-// Test abort() aborts in progress send
-void tst_qmlxmlhttprequest::abort()
-{
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("abort.expect"),
- TEST_FILE("abort.reply"),
- TEST_FILE("testdocument.html")));
-
- QmlComponent component(&engine, TEST_FILE("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);
-
- TRY_WAIT(object->property("dataOK").toBool() == true);
-
- delete object;
-}
-
-void tst_qmlxmlhttprequest::getResponseHeader()
-{
- QmlEngine engine; // Avoid cookie contamination
-
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("getResponseHeader.expect"),
- TEST_FILE("getResponseHeader.reply"),
- TEST_FILE("testdocument.html")));
-
-
- QmlComponent component(&engine, TEST_FILE("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);
-
- TRY_WAIT(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_qmlxmlhttprequest::getResponseHeader_unsent()
-{
- QmlComponent component(&engine, TEST_FILE("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_qmlxmlhttprequest::getResponseHeader_sent()
-{
- QmlComponent component(&engine, TEST_FILE("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_qmlxmlhttprequest::getResponseHeader_args()
-{
- QmlComponent component(&engine, TEST_FILE("getResponseHeader_args.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- TRY_WAIT(object->property("exceptionThrown").toBool() == true);
-
- delete object;
-}
-
-void tst_qmlxmlhttprequest::getAllResponseHeaders()
-{
- QmlEngine engine; // Avoid cookie contamination
-
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("getResponseHeader.expect"),
- TEST_FILE("getResponseHeader.reply"),
- TEST_FILE("testdocument.html")));
-
- QmlComponent component(&engine, TEST_FILE("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);
-
- TRY_WAIT(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_qmlxmlhttprequest::getAllResponseHeaders_unsent()
-{
- QmlComponent component(&engine, TEST_FILE("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_qmlxmlhttprequest::getAllResponseHeaders_sent()
-{
- QmlComponent component(&engine, TEST_FILE("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_qmlxmlhttprequest::getAllResponseHeaders_args()
-{
- QmlComponent component(&engine, TEST_FILE("getAllResponseHeaders_args.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- TRY_WAIT(object->property("exceptionThrown").toBool() == true);
-
- delete object;
-}
-
-void tst_qmlxmlhttprequest::status()
-{
- {
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("status.expect"),
- TEST_FILE("status.200.reply"),
- TEST_FILE("testdocument.html")));
-
- QmlComponent component(&engine, TEST_FILE("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", 200);
- component.completeCreate();
-
- TRY_WAIT(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;
- }
-
- {
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("status.expect"),
- TEST_FILE("status.404.reply"),
- TEST_FILE("testdocument.html")));
-
- QmlComponent component(&engine, TEST_FILE("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", 404);
- component.completeCreate();
-
- TRY_WAIT(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_qmlxmlhttprequest::statusText()
-{
- {
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("status.expect"),
- TEST_FILE("status.200.reply"),
- TEST_FILE("testdocument.html")));
-
- QmlComponent component(&engine, TEST_FILE("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", "OK");
- component.completeCreate();
-
- TRY_WAIT(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;
- }
-
- {
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("status.expect"),
- TEST_FILE("status.404.reply"),
- TEST_FILE("testdocument.html")));
-
- QmlComponent component(&engine, TEST_FILE("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", "Document not found");
- component.completeCreate();
-
- TRY_WAIT(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_qmlxmlhttprequest::responseText()
-{
- {
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("status.expect"),
- TEST_FILE("status.200.reply"),
- TEST_FILE("testdocument.html")));
-
- QmlComponent component(&engine, TEST_FILE("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", "QML Rocks!\n");
- component.completeCreate();
-
- TRY_WAIT(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;
- }
-
- {
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("status.expect"),
- TEST_FILE("status.200.reply"),
- QUrl()));
-
- QmlComponent component(&engine, TEST_FILE("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", "");
- component.completeCreate();
-
- TRY_WAIT(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;
- }
-
- {
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("status.expect"),
- TEST_FILE("status.404.reply"),
- TEST_FILE("testdocument.html")));
-
- QmlComponent component(&engine, TEST_FILE("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", "");
- component.completeCreate();
-
- TRY_WAIT(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;
- }
-}
-
-// Test that calling hte XMLHttpRequest methods on a non-XMLHttpRequest object
-// throws an exception
-void tst_qmlxmlhttprequest::invalidMethodUsage()
-{
- QmlComponent component(&engine, TEST_FILE("invalidMethodUsage.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("onreadystatechange").toBool(), true);
- 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_qmlxmlhttprequest::redirects()
-{
- {
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- server.addRedirect("redirect.html", "http://127.0.0.1:14445/redirecttarget.html");
- server.serveDirectory("data");
-
- QmlComponent component(&engine, TEST_FILE("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();
-
- TRY_WAIT(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("data");
-
- QmlComponent component(&engine, TEST_FILE("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();
-
- TRY_WAIT(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("data");
-
- QmlComponent component(&engine, TEST_FILE("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_qmlxmlhttprequest::responseXML_invalid()
-{
- QmlComponent component(&engine, TEST_FILE("responseXML_invalid.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- TRY_WAIT(object->property("dataOK").toBool() == true);
-
- QCOMPARE(object->property("xmlNull").toBool(), true);
-
- delete object;
-}
-
-// Test the Document DOM element
-void tst_qmlxmlhttprequest::document()
-{
- QmlComponent component(&engine, TEST_FILE("document.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- TRY_WAIT(object->property("dataOK").toBool() == true);
-
- QCOMPARE(object->property("xmlTest").toBool(), true);
-
- delete object;
-}
-
-// Test the Element DOM element
-void tst_qmlxmlhttprequest::element()
-{
- QmlComponent component(&engine, TEST_FILE("element.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- TRY_WAIT(object->property("dataOK").toBool() == true);
-
- QCOMPARE(object->property("xmlTest").toBool(), true);
-
- delete object;
-}
-
-// Test the Attr DOM element
-void tst_qmlxmlhttprequest::attr()
-{
- QmlComponent component(&engine, TEST_FILE("attr.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- TRY_WAIT(object->property("dataOK").toBool() == true);
-
- QCOMPARE(object->property("xmlTest").toBool(), true);
-
- delete object;
-}
-
-// Test the Text DOM element
-void tst_qmlxmlhttprequest::text()
-{
- QmlComponent component(&engine, TEST_FILE("text.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- TRY_WAIT(object->property("dataOK").toBool() == true);
-
- QCOMPARE(object->property("xmlTest").toBool(), true);
-
- delete object;
-}
-
-// Test the CDataSection DOM element
-void tst_qmlxmlhttprequest::cdata()
-{
- QmlComponent component(&engine, TEST_FILE("cdata.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- TRY_WAIT(object->property("dataOK").toBool() == true);
-
- QCOMPARE(object->property("xmlTest").toBool(), true);
-
- delete object;
-}
-
-QTEST_MAIN(tst_qmlxmlhttprequest)
-
-#include "tst_qmlxmlhttprequest.moc"
diff --git a/tests/auto/declarative/qmlxmllistmodel/qmlxmllistmodel.pro b/tests/auto/declarative/qmlxmllistmodel/qmlxmllistmodel.pro
deleted file mode 100644
index 8e58a32..0000000
--- a/tests/auto/declarative/qmlxmllistmodel/qmlxmllistmodel.pro
+++ /dev/null
@@ -1,11 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative gui
-contains(QT_CONFIG,xmlpatterns) {
- QT += xmlpatterns
- DEFINES += QTEST_XMLPATTERNS
-}
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qmlxmllistmodel.cpp
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmlxmllistmodel/tst_qmlxmllistmodel.cpp b/tests/auto/declarative/qmlxmllistmodel/tst_qmlxmllistmodel.cpp
deleted file mode 100644
index df1931f..0000000
--- a/tests/auto/declarative/qmlxmllistmodel/tst_qmlxmllistmodel.cpp
+++ /dev/null
@@ -1,203 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-
-#ifdef QTEST_XMLPATTERNS
-#include <QtDeclarative/qmlengine.h>
-#include <QtDeclarative/qmlcomponent.h>
-#include <private/qmlxmllistmodel_p.h>
-#include "../../../shared/util.h"
-
-class tst_qmlxmllistmodel : public QObject
-
-{
- Q_OBJECT
-public:
- tst_qmlxmllistmodel() {}
-
-private slots:
- void buildModel();
- void missingFields();
- void cdata();
- void attributes();
- void roles();
- void roleErrors();
- void uniqueRoleNames();
-
-private:
- QmlEngine engine;
-};
-
-void tst_qmlxmllistmodel::buildModel()
-{
- QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/model.qml"));
- QmlXmlListModel *listModel = qobject_cast<QmlXmlListModel*>(component.create());
- QVERIFY(listModel != 0);
- QTRY_COMPARE(listModel->count(), 9);
-
- QList<int> roles;
- roles << Qt::UserRole << Qt::UserRole + 1 << Qt::UserRole + 2 << Qt::UserRole + 3;
- QHash<int, QVariant> data = listModel->data(3, roles);
- QVERIFY(data.count() == 4);
- QCOMPARE(data.value(Qt::UserRole).toString(), QLatin1String("Spot"));
- QCOMPARE(data.value(Qt::UserRole+1).toString(), QLatin1String("Dog"));
- QCOMPARE(data.value(Qt::UserRole+2).toInt(), 9);
- QCOMPARE(data.value(Qt::UserRole+3).toString(), QLatin1String("Medium"));
-
- delete listModel;
-}
-
-void tst_qmlxmllistmodel::missingFields()
-{
- QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/model2.qml"));
- QmlXmlListModel *listModel = qobject_cast<QmlXmlListModel*>(component.create());
- QVERIFY(listModel != 0);
- QTRY_COMPARE(listModel->count(), 9);
-
- QList<int> roles;
- roles << Qt::UserRole << Qt::UserRole + 1 << Qt::UserRole + 2 << Qt::UserRole + 3 << Qt::UserRole + 4;
- QHash<int, QVariant> data = listModel->data(5, roles);
- QVERIFY(data.count() == 5);
- QCOMPARE(data.value(Qt::UserRole+3).toString(), QLatin1String(""));
- QCOMPARE(data.value(Qt::UserRole+4).toString(), QLatin1String(""));
-
- data = listModel->data(7, roles);
- QVERIFY(data.count() == 5);
- QCOMPARE(data.value(Qt::UserRole+2).toString(), QLatin1String(""));
-
- delete listModel;
-}
-
-void tst_qmlxmllistmodel::cdata()
-{
- QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/recipes.qml"));
- QmlXmlListModel *listModel = qobject_cast<QmlXmlListModel*>(component.create());
- QVERIFY(listModel != 0);
- QTRY_COMPARE(listModel->count(), 5);
-
- QList<int> roles;
- roles << Qt::UserRole + 2;
- QHash<int, QVariant> data = listModel->data(2, roles);
- QVERIFY(data.count() == 1);
- QVERIFY(data.value(Qt::UserRole+2).toString().startsWith(QLatin1String("<html>")));
-
- delete listModel;
-}
-
-void tst_qmlxmllistmodel::attributes()
-{
- QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/recipes.qml"));
- QmlXmlListModel *listModel = qobject_cast<QmlXmlListModel*>(component.create());
- QVERIFY(listModel != 0);
- QTRY_COMPARE(listModel->count(), 5);
-
- QList<int> roles;
- roles << Qt::UserRole;
- QHash<int, QVariant> data = listModel->data(2, roles);
- QVERIFY(data.count() == 1);
- QCOMPARE(data.value(Qt::UserRole).toString(), QLatin1String("Vegetable Soup"));
-
- delete listModel;
-}
-
-void tst_qmlxmllistmodel::roles()
-{
- QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/model.qml"));
- QmlXmlListModel *listModel = qobject_cast<QmlXmlListModel*>(component.create());
- QVERIFY(listModel != 0);
- QTRY_COMPARE(listModel->count(), 9);
-
- QList<int> roles = listModel->roles();
- QCOMPARE(roles.count(), 4);
- QCOMPARE(listModel->toString(roles.at(0)), QLatin1String("name"));
- QCOMPARE(listModel->toString(roles.at(1)), QLatin1String("type"));
- QCOMPARE(listModel->toString(roles.at(2)), QLatin1String("age"));
- QCOMPARE(listModel->toString(roles.at(3)), QLatin1String("size"));
-
- delete listModel;
-}
-
-void tst_qmlxmllistmodel::roleErrors()
-{
- QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/roleErrors.qml"));
- QTest::ignoreMessage(QtWarningMsg, QString("QML XmlRole (" + QUrl::fromLocalFile(SRCDIR "/data/roleErrors.qml").toString() + ":6:5) An XmlRole query must not start with '/'").toUtf8().constData());
- //### make sure we receive all expected warning messages.
- QmlXmlListModel *listModel = qobject_cast<QmlXmlListModel*>(component.create());
- QVERIFY(listModel != 0);
- QTRY_COMPARE(listModel->count(), 9);
-
- QList<int> roles;
- roles << Qt::UserRole << Qt::UserRole + 1 << Qt::UserRole + 2 << Qt::UserRole + 3;
- QHash<int, QVariant> data = listModel->data(3, roles);
- QVERIFY(data.count() == 4);
-
- //### should any of these return valid values?
- QCOMPARE(data.value(Qt::UserRole), QVariant());
- QCOMPARE(data.value(Qt::UserRole+1), QVariant());
- QCOMPARE(data.value(Qt::UserRole+2), QVariant());
-
- QEXPECT_FAIL("", "QT-2456", Continue);
- QCOMPARE(data.value(Qt::UserRole+3), QVariant());
-
- delete listModel;
-}
-
-void tst_qmlxmllistmodel::uniqueRoleNames()
-{
- QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/unique.qml"));
- QTest::ignoreMessage(QtWarningMsg, QString("QML XmlRole (" + QUrl::fromLocalFile(SRCDIR "/data/unique.qml").toString() + ":7:5) \"name\" duplicates a previous role name and will be disabled.").toUtf8().constData());
- QmlXmlListModel *listModel = qobject_cast<QmlXmlListModel*>(component.create());
- QVERIFY(listModel != 0);
- QTRY_COMPARE(listModel->count(), 9);
-
- QList<int> roles = listModel->roles();
- QCOMPARE(roles.count(), 1);
-
- delete listModel;
-}
-
-QTEST_MAIN(tst_qmlxmllistmodel)
-
-#include "tst_qmlxmllistmodel.moc"
-
-#else
-QTEST_NOOP_MAIN
-#endif
diff --git a/tests/auto/declarative/qpacketprotocol/tst_qpacketprotocol.cpp b/tests/auto/declarative/qpacketprotocol/tst_qpacketprotocol.cpp
index 45947e3..2621d65 100644
--- a/tests/auto/declarative/qpacketprotocol/tst_qpacketprotocol.cpp
+++ b/tests/auto/declarative/qpacketprotocol/tst_qpacketprotocol.cpp
@@ -117,7 +117,7 @@ void tst_QPacketProtocol::setMaximumPacketSize()
QByteArray b;
b.fill('a', size + 1);
out.send() << b.constData();
- QVERIFY(QmlDebugTest::waitForSignal(&in, SIGNAL(invalidPacket())));
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&in, SIGNAL(invalidPacket())));
}
}
@@ -149,7 +149,7 @@ void tst_QPacketProtocol::send()
out.send(packet);
}
- QVERIFY(QmlDebugTest::waitForSignal(&in, SIGNAL(readyRead())));
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&in, SIGNAL(readyRead())));
QPacket p = in.read();
p >> ba >> num;
@@ -178,7 +178,7 @@ void tst_QPacketProtocol::packetsAvailable()
for (int i=0; i<packetCount; i++)
out.send() << "Hello";
- QVERIFY(QmlDebugTest::waitForSignal(&in, SIGNAL(readyRead())));
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&in, SIGNAL(readyRead())));
QCOMPARE(in.packetsAvailable(), qint64(packetCount));
}
@@ -198,7 +198,7 @@ void tst_QPacketProtocol::clear()
out.send() << 123;
out.send() << 456;
- QVERIFY(QmlDebugTest::waitForSignal(&in, SIGNAL(readyRead())));
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&in, SIGNAL(readyRead())));
in.clear();
QVERIFY(in.read().isEmpty());
@@ -213,7 +213,7 @@ void tst_QPacketProtocol::read()
out.send() << 123;
out.send() << 456;
- QVERIFY(QmlDebugTest::waitForSignal(&in, SIGNAL(readyRead())));
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&in, SIGNAL(readyRead())));
int num;
@@ -253,7 +253,7 @@ void tst_QPacketProtocol::tst_QPacket_clear()
QByteArray ba;
int num;
QPacketProtocol in(m_serverConn);
- QVERIFY(QmlDebugTest::waitForSignal(&in, SIGNAL(readyRead())));
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&in, SIGNAL(readyRead())));
QPacket p1 = in.read();
p1 >> ba >> num;
diff --git a/tests/auto/declarative/shared/debugutil.cpp b/tests/auto/declarative/shared/debugutil.cpp
index 864bb63..66f04e5 100644
--- a/tests/auto/declarative/shared/debugutil.cpp
+++ b/tests/auto/declarative/shared/debugutil.cpp
@@ -42,14 +42,14 @@
#include <QEventLoop>
#include <QTimer>
-#include <private/qmldebugclient_p.h>
-#include <private/qmldebugservice_p.h>
+#include <private/qdeclarativedebugclient_p.h>
+#include <private/qdeclarativedebugservice_p.h>
#include "debugutil_p.h"
#include <iostream>
-bool QmlDebugTest::waitForSignal(QObject *receiver, const char *member, int timeout) {
+bool QDeclarativeDebugTest::waitForSignal(QObject *receiver, const char *member, int timeout) {
QEventLoop loop;
QTimer timer;
QObject::connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit()));
@@ -60,17 +60,17 @@ bool QmlDebugTest::waitForSignal(QObject *receiver, const char *member, int time
}
-QmlDebugTestData::QmlDebugTestData(QEventLoop *el)
+QDeclarativeDebugTestData::QDeclarativeDebugTestData(QEventLoop *el)
: exitCode(-1), loop(el)
{
}
-QmlDebugTestData::~QmlDebugTestData()
+QDeclarativeDebugTestData::~QDeclarativeDebugTestData()
{
qDeleteAll(items);
}
-void QmlDebugTestData::testsFinished(int code)
+void QDeclarativeDebugTestData::testsFinished(int code)
{
exitCode = code;
loop->quit();
@@ -78,56 +78,56 @@ void QmlDebugTestData::testsFinished(int code)
-QmlDebugTestService::QmlDebugTestService(const QString &s, QObject *parent)
- : QmlDebugService(s, parent), enabled(false)
+QDeclarativeDebugTestService::QDeclarativeDebugTestService(const QString &s, QObject *parent)
+ : QDeclarativeDebugService(s, parent), enabled(false)
{
}
-void QmlDebugTestService::messageReceived(const QByteArray &ba)
+void QDeclarativeDebugTestService::messageReceived(const QByteArray &ba)
{
sendMessage(ba);
}
-void QmlDebugTestService::enabledChanged(bool e)
+void QDeclarativeDebugTestService::enabledChanged(bool e)
{
enabled = e;
emit enabledStateChanged();
}
-QmlDebugTestClient::QmlDebugTestClient(const QString &s, QmlDebugConnection *c)
- : QmlDebugClient(s, c)
+QDeclarativeDebugTestClient::QDeclarativeDebugTestClient(const QString &s, QDeclarativeDebugConnection *c)
+ : QDeclarativeDebugClient(s, c)
{
}
-QByteArray QmlDebugTestClient::waitForResponse()
+QByteArray QDeclarativeDebugTestClient::waitForResponse()
{
lastMsg.clear();
- QmlDebugTest::waitForSignal(this, SIGNAL(serverMessage(QByteArray)));
+ QDeclarativeDebugTest::waitForSignal(this, SIGNAL(serverMessage(QByteArray)));
if (lastMsg.isEmpty()) {
- qWarning() << "tst_QmlDebugClient: no response from server!";
+ qWarning() << "tst_QDeclarativeDebugClient: no response from server!";
return QByteArray();
}
return lastMsg;
}
-void QmlDebugTestClient::messageReceived(const QByteArray &ba)
+void QDeclarativeDebugTestClient::messageReceived(const QByteArray &ba)
{
lastMsg = ba;
emit serverMessage(ba);
}
-tst_QmlDebug_Thread::tst_QmlDebug_Thread(QmlDebugTestData *data, QmlTestFactory *factory)
+tst_QDeclarativeDebug_Thread::tst_QDeclarativeDebug_Thread(QDeclarativeDebugTestData *data, QDeclarativeTestFactory *factory)
: m_data(data), m_factory(factory)
{
}
-void tst_QmlDebug_Thread::run()
+void tst_QDeclarativeDebug_Thread::run()
{
bool ok = false;
- QmlDebugConnection conn;
+ QDeclarativeDebugConnection conn;
conn.connectToHost("127.0.0.1", 3768);
ok = conn.waitForConnected();
Q_ASSERT(ok);
@@ -146,25 +146,25 @@ void tst_QmlDebug_Thread::run()
emit testsFinished(code);
}
-int QmlDebugTest::runTests(QmlTestFactory *factory, const QList<QByteArray> &qml)
+int QDeclarativeDebugTest::runTests(QDeclarativeTestFactory *factory, const QList<QByteArray> &qml)
{
qputenv("QML_DEBUG_SERVER_PORT", "3768");
QEventLoop loop;
- QmlDebugTestData data(&loop);
+ QDeclarativeDebugTestData data(&loop);
- tst_QmlDebug_Thread thread(&data, factory);
+ tst_QDeclarativeDebug_Thread thread(&data, factory);
QObject::connect(&thread, SIGNAL(testsFinished(int)), &data, SLOT(testsFinished(int)));
- QmlDebugService::notifyOnServerStart(&thread, "start");
+ QDeclarativeDebugService::notifyOnServerStart(&thread, "start");
- QmlEngine engine; // blocks until client connects
+ QDeclarativeEngine engine; // blocks until client connects
foreach (const QByteArray &code, qml) {
- QmlComponent c(&engine);
+ QDeclarativeComponent c(&engine);
c.setData(code, QUrl::fromLocalFile(""));
Q_ASSERT(c.isReady()); // fails if bad syntax
- data.items << qobject_cast<QmlGraphicsItem*>(c.create());
+ data.items << qobject_cast<QDeclarativeItem*>(c.create());
}
// start the test
diff --git a/tests/auto/declarative/shared/debugutil_p.h b/tests/auto/declarative/shared/debugutil_p.h
index 6815b3c..c152b5a 100644
--- a/tests/auto/declarative/shared/debugutil_p.h
+++ b/tests/auto/declarative/shared/debugutil_p.h
@@ -45,37 +45,37 @@
#include <QThread>
#include <QTest>
-#include <QtDeclarative/qmlengine.h>
+#include <QtDeclarative/qdeclarativeengine.h>
-#include <private/qmldebugclient_p.h>
-#include <private/qmldebugservice_p.h>
-#include <private/qmlgraphicsitem_p.h>
+#include <private/qdeclarativedebugclient_p.h>
+#include <private/qdeclarativedebugservice_p.h>
+#include <private/qdeclarativeitem_p.h>
-class QmlTestFactory;
+class QDeclarativeTestFactory;
-class QmlDebugTest
+class QDeclarativeDebugTest
{
public:
static bool waitForSignal(QObject *receiver, const char *member, int timeout = 5000);
- static int runTests(QmlTestFactory *factory, const QList<QByteArray> &qml = QList<QByteArray>());
+ static int runTests(QDeclarativeTestFactory *factory, const QList<QByteArray> &qml = QList<QByteArray>());
};
-class QmlDebugTestData : public QObject
+class QDeclarativeDebugTestData : public QObject
{
Q_OBJECT
public:
- QmlDebugTestData(QEventLoop *el);
+ QDeclarativeDebugTestData(QEventLoop *el);
- ~QmlDebugTestData();
+ ~QDeclarativeDebugTestData();
- QmlDebugConnection *conn;
- QmlEngine *engine;
+ QDeclarativeDebugConnection *conn;
+ QDeclarativeEngine *engine;
int exitCode;
QEventLoop *loop;
- QList<QmlGraphicsItem *> items;
+ QList<QDeclarativeItem *> items;
signals:
void engineCreated();
@@ -84,24 +84,24 @@ public slots:
void testsFinished(int code);
private:
- friend class QmlDebugTest;
+ friend class QDeclarativeDebugTest;
};
-class QmlTestFactory
+class QDeclarativeTestFactory
{
public:
- QmlTestFactory() {}
- virtual ~QmlTestFactory() {}
+ QDeclarativeTestFactory() {}
+ virtual ~QDeclarativeTestFactory() {}
- virtual QObject *createTest(QmlDebugTestData *data) = 0;
+ virtual QObject *createTest(QDeclarativeDebugTestData *data) = 0;
};
-class QmlDebugTestService : public QmlDebugService
+class QDeclarativeDebugTestService : public QDeclarativeDebugService
{
Q_OBJECT
public:
- QmlDebugTestService(const QString &s, QObject *parent = 0);
+ QDeclarativeDebugTestService(const QString &s, QObject *parent = 0);
bool enabled;
signals:
@@ -113,11 +113,11 @@ protected:
virtual void enabledChanged(bool e);
};
-class QmlDebugTestClient : public QmlDebugClient
+class QDeclarativeDebugTestClient : public QDeclarativeDebugClient
{
Q_OBJECT
public:
- QmlDebugTestClient(const QString &s, QmlDebugConnection *c);
+ QDeclarativeDebugTestClient(const QString &s, QDeclarativeDebugConnection *c);
QByteArray waitForResponse();
@@ -131,11 +131,11 @@ private:
QByteArray lastMsg;
};
-class tst_QmlDebug_Thread : public QThread
+class tst_QDeclarativeDebug_Thread : public QThread
{
Q_OBJECT
public:
- tst_QmlDebug_Thread(QmlDebugTestData *data, QmlTestFactory *factory);
+ tst_QDeclarativeDebug_Thread(QDeclarativeDebugTestData *data, QDeclarativeTestFactory *factory);
void run();
@@ -143,8 +143,8 @@ signals:
void testsFinished(int);
private:
- QmlDebugTestData *m_data;
- QmlTestFactory *m_factory;
+ QDeclarativeDebugTestData *m_data;
+ QDeclarativeTestFactory *m_factory;
};
diff --git a/tests/auto/declarative/sql/tst_sql.cpp b/tests/auto/declarative/sql/tst_sql.cpp
index 2384101..e8a5e0c 100644
--- a/tests/auto/declarative/sql/tst_sql.cpp
+++ b/tests/auto/declarative/sql/tst_sql.cpp
@@ -40,10 +40,10 @@
****************************************************************************/
#include <qtest.h>
#include "../../../shared/util.h"
-#include <QtDeclarative/qmlengine.h>
-#include <QtDeclarative/qmlcomponent.h>
-#include <private/qmlgraphicstext_p.h>
-#include <private/qmlengine_p.h>
+#include <QtDeclarative/qdeclarativeengine.h>
+#include <QtDeclarative/qdeclarativecomponent.h>
+#include <private/qdeclarativetext_p.h>
+#include <private/qdeclarativeengine_p.h>
#include <QtCore/qcryptographichash.h>
#include <QtWebKit/qwebpage.h>
#include <QtWebKit/qwebframe.h>
@@ -62,7 +62,7 @@ public:
qApp->setApplicationName("tst_sql");
qApp->setOrganizationName("Nokia");
qApp->setOrganizationDomain("nokia.com");
- engine = new QmlEngine;
+ engine = new QDeclarativeEngine;
}
~tst_sql()
@@ -85,7 +85,7 @@ private slots:
private:
QString dbDir() const;
- QmlEngine *engine;
+ QDeclarativeEngine *engine;
};
class QWebPageWithJavaScriptConsoleMessages : public QWebPage {
@@ -200,9 +200,9 @@ void tst_sql::testQml()
"Text { Script { source: \""+jsfile+"\" } text: test() }";
engine->setOfflineStoragePath(dbDir());
- QmlComponent component(engine);
+ QDeclarativeComponent component(engine);
component.setData(qml.toUtf8(), QUrl::fromLocalFile(SRCDIR "/empty.qml")); // just a file for relative local imports
- QmlGraphicsText *text = qobject_cast<QmlGraphicsText*>(component.create());
+ QDeclarativeText *text = qobject_cast<QDeclarativeText*>(component.create());
QVERIFY(text != 0);
QCOMPARE(text->text(),QString("passed"));
}
@@ -221,7 +221,7 @@ void tst_sql::testQml_cleanopen()
// making it more like the tests are running in new processes.
testQml();
- QmlEnginePrivate::getScriptEngine(engine)->collectGarbage(); // close databases
+ QDeclarativeEnginePrivate::getScriptEngine(engine)->collectGarbage(); // close databases
foreach (QString dbname, QSqlDatabase::connectionNames()) {
QSqlDatabase::removeDatabase(dbname);
}
diff --git a/tests/auto/declarative/visual/Package_Views/packageviews.qml b/tests/auto/declarative/visual/Package_Views/packageviews.qml
index b577e45..cf3f9f7 100644
--- a/tests/auto/declarative/visual/Package_Views/packageviews.qml
+++ b/tests/auto/declarative/visual/Package_Views/packageviews.qml
@@ -64,7 +64,7 @@ Rectangle {
from: "*"; to: "*"
SequentialAnimation {
ParentAction{}
- NumberAnimation { properties: "x,y,width"; easing: "easeInOutQuad" }
+ NumberAnimation { properties: "x,y,width"; easing.type: "InOutQuad" }
}
}
]
diff --git a/tests/auto/declarative/visual/animation/easing/easing.qml b/tests/auto/declarative/visual/animation/easing/easing.qml
index 9c814eb..4248d88 100644
--- a/tests/auto/declarative/visual/animation/easing/easing.qml
+++ b/tests/auto/declarative/visual/animation/easing/easing.qml
@@ -9,127 +9,127 @@ Rectangle {
ListModel {
id: easingtypes
ListElement {
- type: "easeLinear"
+ type: "Linear"
}
ListElement {
- type: "easeInQuad"
+ type: "InQuad"
}
ListElement {
- type: "easeOutQuad"
+ type: "OutQuad"
}
ListElement {
- type: "easeInOutQuad"
+ type: "InOutQuad"
}
ListElement {
- type: "easeOutInQuad"
+ type: "OutInQuad"
}
ListElement {
- type: "easeInCubic"
+ type: "InCubic"
}
ListElement {
- type: "easeOutCubic"
+ type: "OutCubic"
}
ListElement {
- type: "easeInOutCubic"
+ type: "InOutCubic"
}
ListElement {
- type: "easeOutInCubic"
+ type: "OutInCubic"
}
ListElement {
- type: "easeInQuart"
+ type: "InQuart"
}
ListElement {
- type: "easeOutQuart"
+ type: "OutQuart"
}
ListElement {
- type: "easeInOutQuart"
+ type: "InOutQuart"
}
ListElement {
- type: "easeOutInQuart"
+ type: "OutInQuart"
}
ListElement {
- type: "easeInQuint"
+ type: "InQuint"
}
ListElement {
- type: "easeOutQuint"
+ type: "OutQuint"
}
ListElement {
- type: "easeInOutQuint"
+ type: "InOutQuint"
}
ListElement {
- type: "easeOutInQuint"
+ type: "OutInQuint"
}
ListElement {
- type: "easeInSine"
+ type: "InSine"
}
ListElement {
- type: "easeOutSine"
+ type: "OutSine"
}
ListElement {
- type: "easeInOutSine"
+ type: "InOutSine"
}
ListElement {
- type: "easeOutInSine"
+ type: "OutInSine"
}
ListElement {
- type: "easeInExpo"
+ type: "InExpo"
}
ListElement {
- type: "easeOutExpo"
+ type: "OutExpo"
}
ListElement {
- type: "easeInOutExpo"
+ type: "InOutExpo"
}
ListElement {
- type: "easeOutInExpo"
+ type: "OutInExpo"
}
ListElement {
- type: "easeInCirc"
+ type: "InCirc"
}
ListElement {
- type: "easeOutCirc"
+ type: "OutCirc"
}
ListElement {
- type: "easeInOutCirc"
+ type: "InOutCirc"
}
ListElement {
- type: "easeOutInCirc"
+ type: "OutInCirc"
}
ListElement {
- type: "easeInElastic"
+ type: "InElastic"
}
ListElement {
- type: "easeOutElastic"
+ type: "OutElastic"
}
ListElement {
- type: "easeInOutElastic"
+ type: "InOutElastic"
}
ListElement {
- type: "easeOutInElastic"
+ type: "OutInElastic"
}
ListElement {
- type: "easeInBack"
+ type: "InBack"
}
ListElement {
- type: "easeOutBack"
+ type: "OutBack"
}
ListElement {
- type: "easeInOutBack"
+ type: "InOutBack"
}
ListElement {
- type: "easeOutInBack"
+ type: "OutInBack"
}
ListElement {
- type: "easeOutBounce"
+ type: "OutBounce"
}
ListElement {
- type: "easeInBounce"
+ type: "InBounce"
}
ListElement {
- type: "easeInOutBounce"
+ type: "InOutBounce"
}
ListElement {
- type: "easeOutInBounce"
+ type: "OutInBounce"
}
}
]
@@ -177,7 +177,7 @@ Rectangle {
reversible: true
NumberAnimation {
properties: "x"
- easing: type
+ easing.type: type
duration: 1000
}
}
diff --git a/tests/auto/declarative/visual/animation/pauseAnimation/pauseAnimation.qml b/tests/auto/declarative/visual/animation/pauseAnimation/pauseAnimation.qml
index f2e065d..24ca76b 100644
--- a/tests/auto/declarative/visual/animation/pauseAnimation/pauseAnimation.qml
+++ b/tests/auto/declarative/visual/animation/pauseAnimation/pauseAnimation.qml
@@ -14,11 +14,11 @@ Rectangle {
repeat: true
NumberAnimation {
to: 0; duration: 500
- easing: "easeInOutQuad"
+ easing.type: "InOutQuad"
}
NumberAnimation {
to: 200-img.height
- easing: "easeOutBounce"
+ easing.type: "OutBounce"
duration: 2000
}
PauseAnimation {
diff --git a/tests/auto/declarative/visual/animation/propertyAction/propertyAction.qml b/tests/auto/declarative/visual/animation/propertyAction/propertyAction.qml
index 593f495..e18e770 100644
--- a/tests/auto/declarative/visual/animation/propertyAction/propertyAction.qml
+++ b/tests/auto/declarative/visual/animation/propertyAction/propertyAction.qml
@@ -28,7 +28,7 @@ Rectangle {
SequentialAnimation {
ColorAnimation {}
PropertyAction { properties: "x" }
- NumberAnimation { properties: "y"; easing: "InOutQuad" }
+ NumberAnimation { properties: "y"; easing.type: "InOutQuad" }
}
}
}
diff --git a/tests/auto/declarative/visual/animation/scriptAction/scriptAction.qml b/tests/auto/declarative/visual/animation/scriptAction/scriptAction.qml
index 30d587a..ef4ed76 100644
--- a/tests/auto/declarative/visual/animation/scriptAction/scriptAction.qml
+++ b/tests/auto/declarative/visual/animation/scriptAction/scriptAction.qml
@@ -27,9 +27,9 @@ Rectangle {
transitions: Transition {
SequentialAnimation {
- NumberAnimation { properties: "x"; easing: "InOutQuad" }
+ NumberAnimation { properties: "x"; easing.type: "InOutQuad" }
ScriptAction { stateChangeScriptName: "setColor" }
- NumberAnimation { properties: "y"; easing: "InOutQuad" }
+ NumberAnimation { properties: "y"; easing.type: "InOutQuad" }
}
}
}
diff --git a/tests/auto/declarative/visual/qmlgraphicsborderimage/animated-smooth.qml b/tests/auto/declarative/visual/qdeclarativeborderimage/animated-smooth.qml
index 0ceaf49..0ceaf49 100644
--- a/tests/auto/declarative/visual/qmlgraphicsborderimage/animated-smooth.qml
+++ b/tests/auto/declarative/visual/qdeclarativeborderimage/animated-smooth.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicsborderimage/animated.qml b/tests/auto/declarative/visual/qdeclarativeborderimage/animated.qml
index 29c02b3..29c02b3 100644
--- a/tests/auto/declarative/visual/qmlgraphicsborderimage/animated.qml
+++ b/tests/auto/declarative/visual/qdeclarativeborderimage/animated.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicsborderimage/borders.qml b/tests/auto/declarative/visual/qdeclarativeborderimage/borders.qml
index 9879416..9879416 100644
--- a/tests/auto/declarative/visual/qmlgraphicsborderimage/borders.qml
+++ b/tests/auto/declarative/visual/qdeclarativeborderimage/borders.qml
diff --git a/tests/auto/declarative/visual/qdeclarativeborderimage/content/MyBorderImage.qml b/tests/auto/declarative/visual/qdeclarativeborderimage/content/MyBorderImage.qml
new file mode 100644
index 0000000..e268ce7
--- /dev/null
+++ b/tests/auto/declarative/visual/qdeclarativeborderimage/content/MyBorderImage.qml
@@ -0,0 +1,38 @@
+import Qt 4.6
+
+Item {
+ property alias horizontalMode: image.horizontalTileMode
+ property alias verticalMode: image.verticalTileMode
+ property alias source: image.source
+ property alias antialiased: image.smooth
+
+ property int minWidth
+ property int minHeight
+ property int maxWidth
+ property int maxHeight
+ property int margin
+
+ id: container
+ width: 240; height: 240
+
+ BorderImage {
+ id: image; x: container.width / 2 - width / 2; y: container.height / 2 - height / 2
+
+ width: SequentialAnimation {
+ repeat: true
+ NumberAnimation { from: container.minWidth; to: container.maxWidth; duration: 2000; easing.type: "InOutQuad"}
+ NumberAnimation { from: container.maxWidth; to: container.minWidth; duration: 2000; easing.type: "InOutQuad" }
+ }
+
+ height: SequentialAnimation {
+ repeat: true
+ NumberAnimation { from: container.minHeight; to: container.maxHeight; duration: 2000; easing.type: "InOutQuad"}
+ NumberAnimation { from: container.maxHeight; to: container.minHeight; duration: 2000; easing.type: "InOutQuad" }
+ }
+
+ border.top: container.margin
+ border.left: container.margin
+ border.bottom: container.margin
+ border.right: container.margin
+ }
+}
diff --git a/tests/auto/declarative/visual/qmlgraphicsborderimage/content/bw.png b/tests/auto/declarative/visual/qdeclarativeborderimage/content/bw.png
index 486eaae..486eaae 100644
--- a/tests/auto/declarative/visual/qmlgraphicsborderimage/content/bw.png
+++ b/tests/auto/declarative/visual/qdeclarativeborderimage/content/bw.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsborderimage/content/colors-round.sci b/tests/auto/declarative/visual/qdeclarativeborderimage/content/colors-round.sci
index 506f6f5..506f6f5 100644
--- a/tests/auto/declarative/visual/qmlgraphicsborderimage/content/colors-round.sci
+++ b/tests/auto/declarative/visual/qdeclarativeborderimage/content/colors-round.sci
diff --git a/tests/auto/declarative/visual/qmlgraphicsborderimage/content/colors-stretch.sci b/tests/auto/declarative/visual/qdeclarativeborderimage/content/colors-stretch.sci
index e4989a7..e4989a7 100644
--- a/tests/auto/declarative/visual/qmlgraphicsborderimage/content/colors-stretch.sci
+++ b/tests/auto/declarative/visual/qdeclarativeborderimage/content/colors-stretch.sci
diff --git a/tests/auto/declarative/visual/qdeclarativeborderimage/content/colors.png b/tests/auto/declarative/visual/qdeclarativeborderimage/content/colors.png
new file mode 100644
index 0000000..dfb62f3
--- /dev/null
+++ b/tests/auto/declarative/visual/qdeclarativeborderimage/content/colors.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated-smooth.0.png b/tests/auto/declarative/visual/qdeclarativeborderimage/data/animated-smooth.0.png
index 9a6b079..9a6b079 100644
--- a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated-smooth.0.png
+++ b/tests/auto/declarative/visual/qdeclarativeborderimage/data/animated-smooth.0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated-smooth.1.png b/tests/auto/declarative/visual/qdeclarativeborderimage/data/animated-smooth.1.png
index 1f960e5..1f960e5 100644
--- a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated-smooth.1.png
+++ b/tests/auto/declarative/visual/qdeclarativeborderimage/data/animated-smooth.1.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated-smooth.2.png b/tests/auto/declarative/visual/qdeclarativeborderimage/data/animated-smooth.2.png
index 85a2729..85a2729 100644
--- a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated-smooth.2.png
+++ b/tests/auto/declarative/visual/qdeclarativeborderimage/data/animated-smooth.2.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated-smooth.3.png b/tests/auto/declarative/visual/qdeclarativeborderimage/data/animated-smooth.3.png
index de6ff7c..de6ff7c 100644
--- a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated-smooth.3.png
+++ b/tests/auto/declarative/visual/qdeclarativeborderimage/data/animated-smooth.3.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated-smooth.4.png b/tests/auto/declarative/visual/qdeclarativeborderimage/data/animated-smooth.4.png
index fe7d3dd..fe7d3dd 100644
--- a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated-smooth.4.png
+++ b/tests/auto/declarative/visual/qdeclarativeborderimage/data/animated-smooth.4.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated-smooth.5.png b/tests/auto/declarative/visual/qdeclarativeborderimage/data/animated-smooth.5.png
index e73bef5..e73bef5 100644
--- a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated-smooth.5.png
+++ b/tests/auto/declarative/visual/qdeclarativeborderimage/data/animated-smooth.5.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated-smooth.6.png b/tests/auto/declarative/visual/qdeclarativeborderimage/data/animated-smooth.6.png
index 0c75422..0c75422 100644
--- a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated-smooth.6.png
+++ b/tests/auto/declarative/visual/qdeclarativeborderimage/data/animated-smooth.6.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated-smooth.qml b/tests/auto/declarative/visual/qdeclarativeborderimage/data/animated-smooth.qml
index 043f5e2..043f5e2 100644
--- a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated-smooth.qml
+++ b/tests/auto/declarative/visual/qdeclarativeborderimage/data/animated-smooth.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated.0.png b/tests/auto/declarative/visual/qdeclarativeborderimage/data/animated.0.png
index 99228f9..99228f9 100644
--- a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated.0.png
+++ b/tests/auto/declarative/visual/qdeclarativeborderimage/data/animated.0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated.1.png b/tests/auto/declarative/visual/qdeclarativeborderimage/data/animated.1.png
index a2dcd00..a2dcd00 100644
--- a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated.1.png
+++ b/tests/auto/declarative/visual/qdeclarativeborderimage/data/animated.1.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated.2.png b/tests/auto/declarative/visual/qdeclarativeborderimage/data/animated.2.png
index 8a80020..8a80020 100644
--- a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated.2.png
+++ b/tests/auto/declarative/visual/qdeclarativeborderimage/data/animated.2.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated.3.png b/tests/auto/declarative/visual/qdeclarativeborderimage/data/animated.3.png
index 02b57ef..02b57ef 100644
--- a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated.3.png
+++ b/tests/auto/declarative/visual/qdeclarativeborderimage/data/animated.3.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated.4.png b/tests/auto/declarative/visual/qdeclarativeborderimage/data/animated.4.png
index df0f6cc..df0f6cc 100644
--- a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated.4.png
+++ b/tests/auto/declarative/visual/qdeclarativeborderimage/data/animated.4.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated.5.png b/tests/auto/declarative/visual/qdeclarativeborderimage/data/animated.5.png
index 0add64d..0add64d 100644
--- a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated.5.png
+++ b/tests/auto/declarative/visual/qdeclarativeborderimage/data/animated.5.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated.6.png b/tests/auto/declarative/visual/qdeclarativeborderimage/data/animated.6.png
index 0886207..0886207 100644
--- a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated.6.png
+++ b/tests/auto/declarative/visual/qdeclarativeborderimage/data/animated.6.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated.7.png b/tests/auto/declarative/visual/qdeclarativeborderimage/data/animated.7.png
index bc1a7b0..bc1a7b0 100644
--- a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated.7.png
+++ b/tests/auto/declarative/visual/qdeclarativeborderimage/data/animated.7.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated.qml b/tests/auto/declarative/visual/qdeclarativeborderimage/data/animated.qml
index 29e591a..29e591a 100644
--- a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated.qml
+++ b/tests/auto/declarative/visual/qdeclarativeborderimage/data/animated.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/borders.0.png b/tests/auto/declarative/visual/qdeclarativeborderimage/data/borders.0.png
index 80cbd26..80cbd26 100644
--- a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/borders.0.png
+++ b/tests/auto/declarative/visual/qdeclarativeborderimage/data/borders.0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/borders.1.png b/tests/auto/declarative/visual/qdeclarativeborderimage/data/borders.1.png
index 80cbd26..80cbd26 100644
--- a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/borders.1.png
+++ b/tests/auto/declarative/visual/qdeclarativeborderimage/data/borders.1.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/borders.2.png b/tests/auto/declarative/visual/qdeclarativeborderimage/data/borders.2.png
index 80cbd26..80cbd26 100644
--- a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/borders.2.png
+++ b/tests/auto/declarative/visual/qdeclarativeborderimage/data/borders.2.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/borders.3.png b/tests/auto/declarative/visual/qdeclarativeborderimage/data/borders.3.png
index 80cbd26..80cbd26 100644
--- a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/borders.3.png
+++ b/tests/auto/declarative/visual/qdeclarativeborderimage/data/borders.3.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/borders.4.png b/tests/auto/declarative/visual/qdeclarativeborderimage/data/borders.4.png
index 80cbd26..80cbd26 100644
--- a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/borders.4.png
+++ b/tests/auto/declarative/visual/qdeclarativeborderimage/data/borders.4.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/borders.qml b/tests/auto/declarative/visual/qdeclarativeborderimage/data/borders.qml
index 16cd5e9..16cd5e9 100644
--- a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/borders.qml
+++ b/tests/auto/declarative/visual/qdeclarativeborderimage/data/borders.qml
diff --git a/tests/auto/declarative/visual/qmleasefollow/data/easefollow.0.png b/tests/auto/declarative/visual/qdeclarativeeasefollow/data/easefollow.0.png
index 21b6afb..21b6afb 100644
--- a/tests/auto/declarative/visual/qmleasefollow/data/easefollow.0.png
+++ b/tests/auto/declarative/visual/qdeclarativeeasefollow/data/easefollow.0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmleasefollow/data/easefollow.1.png b/tests/auto/declarative/visual/qdeclarativeeasefollow/data/easefollow.1.png
index bb8a02b..bb8a02b 100644
--- a/tests/auto/declarative/visual/qmleasefollow/data/easefollow.1.png
+++ b/tests/auto/declarative/visual/qdeclarativeeasefollow/data/easefollow.1.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmleasefollow/data/easefollow.2.png b/tests/auto/declarative/visual/qdeclarativeeasefollow/data/easefollow.2.png
index da60237..da60237 100644
--- a/tests/auto/declarative/visual/qmleasefollow/data/easefollow.2.png
+++ b/tests/auto/declarative/visual/qdeclarativeeasefollow/data/easefollow.2.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmleasefollow/data/easefollow.3.png b/tests/auto/declarative/visual/qdeclarativeeasefollow/data/easefollow.3.png
index 3e943e8..3e943e8 100644
--- a/tests/auto/declarative/visual/qmleasefollow/data/easefollow.3.png
+++ b/tests/auto/declarative/visual/qdeclarativeeasefollow/data/easefollow.3.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmleasefollow/data/easefollow.4.png b/tests/auto/declarative/visual/qdeclarativeeasefollow/data/easefollow.4.png
index 4fbaf26..4fbaf26 100644
--- a/tests/auto/declarative/visual/qmleasefollow/data/easefollow.4.png
+++ b/tests/auto/declarative/visual/qdeclarativeeasefollow/data/easefollow.4.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmleasefollow/data/easefollow.5.png b/tests/auto/declarative/visual/qdeclarativeeasefollow/data/easefollow.5.png
index c10d196..c10d196 100644
--- a/tests/auto/declarative/visual/qmleasefollow/data/easefollow.5.png
+++ b/tests/auto/declarative/visual/qdeclarativeeasefollow/data/easefollow.5.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmleasefollow/data/easefollow.6.png b/tests/auto/declarative/visual/qdeclarativeeasefollow/data/easefollow.6.png
index a672c06..a672c06 100644
--- a/tests/auto/declarative/visual/qmleasefollow/data/easefollow.6.png
+++ b/tests/auto/declarative/visual/qdeclarativeeasefollow/data/easefollow.6.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmleasefollow/data/easefollow.qml b/tests/auto/declarative/visual/qdeclarativeeasefollow/data/easefollow.qml
index 029a2fc..029a2fc 100644
--- a/tests/auto/declarative/visual/qmleasefollow/data/easefollow.qml
+++ b/tests/auto/declarative/visual/qdeclarativeeasefollow/data/easefollow.qml
diff --git a/tests/auto/declarative/visual/qmleasefollow/easefollow.qml b/tests/auto/declarative/visual/qdeclarativeeasefollow/easefollow.qml
index bd3270f..bd3270f 100644
--- a/tests/auto/declarative/visual/qmleasefollow/easefollow.qml
+++ b/tests/auto/declarative/visual/qdeclarativeeasefollow/easefollow.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-horizontal.0.png b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-horizontal.0.png
index 016902b..016902b 100644
--- a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-horizontal.0.png
+++ b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-horizontal.0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-horizontal.1.png b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-horizontal.1.png
index a654936..a654936 100644
--- a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-horizontal.1.png
+++ b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-horizontal.1.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-horizontal.2.png b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-horizontal.2.png
index cfd5517..cfd5517 100644
--- a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-horizontal.2.png
+++ b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-horizontal.2.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-horizontal.3.png b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-horizontal.3.png
index 016902b..016902b 100644
--- a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-horizontal.3.png
+++ b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-horizontal.3.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-horizontal.qml b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-horizontal.qml
index 46086f9..46086f9 100644
--- a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-horizontal.qml
+++ b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-horizontal.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.0.png b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.0.png
index 18fef53..18fef53 100644
--- a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.0.png
+++ b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.1.png b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.1.png
index 18fef53..18fef53 100644
--- a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.1.png
+++ b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.1.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.10.png b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.10.png
index b352c68..b352c68 100644
--- a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.10.png
+++ b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.10.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.11.png b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.11.png
index ce7ee68..ce7ee68 100644
--- a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.11.png
+++ b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.11.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.12.png b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.12.png
index d8cdacf..d8cdacf 100644
--- a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.12.png
+++ b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.12.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.13.png b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.13.png
index 0c2fa7b..0c2fa7b 100644
--- a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.13.png
+++ b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.13.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.14.png b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.14.png
index e9b3028..e9b3028 100644
--- a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.14.png
+++ b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.14.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.15.png b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.15.png
index 2186a8b..2186a8b 100644
--- a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.15.png
+++ b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.15.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.16.png b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.16.png
index b4590af..b4590af 100644
--- a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.16.png
+++ b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.16.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.17.png b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.17.png
index fe29f19..fe29f19 100644
--- a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.17.png
+++ b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.17.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.18.png b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.18.png
index fe29f19..fe29f19 100644
--- a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.18.png
+++ b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.18.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.19.png b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.19.png
index 4f8587f..4f8587f 100644
--- a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.19.png
+++ b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.19.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.2.png b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.2.png
index 0a7cc03..0a7cc03 100644
--- a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.2.png
+++ b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.2.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.20.png b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.20.png
index 4f8587f..4f8587f 100644
--- a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.20.png
+++ b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.20.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.21.png b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.21.png
index c0b0bdf..c0b0bdf 100644
--- a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.21.png
+++ b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.21.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.22.png b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.22.png
index 4168c3b..4168c3b 100644
--- a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.22.png
+++ b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.22.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.23.png b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.23.png
index 18fef53..18fef53 100644
--- a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.23.png
+++ b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.23.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.24.png b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.24.png
index e69de29..e69de29 100644
--- a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.24.png
+++ b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.24.png
diff --git a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.3.png b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.3.png
index fc6669d..fc6669d 100644
--- a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.3.png
+++ b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.3.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.4.png b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.4.png
index c0b0bdf..c0b0bdf 100644
--- a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.4.png
+++ b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.4.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.5.png b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.5.png
index 2ffa96e..2ffa96e 100644
--- a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.5.png
+++ b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.5.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.6.png b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.6.png
index f550b89..f550b89 100644
--- a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.6.png
+++ b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.6.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.7.png b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.7.png
index f550b89..f550b89 100644
--- a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.7.png
+++ b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.7.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.8.png b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.8.png
index f550b89..f550b89 100644
--- a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.8.png
+++ b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.8.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.9.png b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.9.png
index f550b89..f550b89 100644
--- a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.9.png
+++ b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.9.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.qml b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.qml
index db70298..db70298 100644
--- a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.qml
+++ b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.qml
diff --git a/tests/auto/declarative/visual/qdeclarativeflickable/flickable-horizontal.qml b/tests/auto/declarative/visual/qdeclarativeflickable/flickable-horizontal.qml
new file mode 100644
index 0000000..50ba9ad
--- /dev/null
+++ b/tests/auto/declarative/visual/qdeclarativeflickable/flickable-horizontal.qml
@@ -0,0 +1,37 @@
+import Qt 4.6
+
+Rectangle {
+ color: "lightSteelBlue"
+ width: 600; height: 300
+
+ ListModel {
+ id: list
+ ListElement { dayColor: "steelblue" }
+ ListElement { dayColor: "blue" }
+ ListElement { dayColor: "yellow" }
+ ListElement { dayColor: "purple" }
+ ListElement { dayColor: "red" }
+ ListElement { dayColor: "green" }
+ ListElement { dayColor: "orange" }
+ }
+
+ Flickable {
+ id: flickable
+ anchors.fill: parent; contentWidth: row.width
+
+ Row {
+ id: row
+ Repeater {
+ model: list
+ Rectangle { width: 200; height: 300; color: dayColor }
+ }
+ }
+ }
+ Rectangle {
+ radius: 3
+ y: flickable.height-8
+ height: 8
+ x: flickable.visibleArea.xPosition * flickable.width
+ width: flickable.visibleArea.widthRatio * flickable.width
+ }
+}
diff --git a/tests/auto/declarative/visual/qdeclarativeflickable/flickable-vertical.qml b/tests/auto/declarative/visual/qdeclarativeflickable/flickable-vertical.qml
new file mode 100644
index 0000000..ebb963d
--- /dev/null
+++ b/tests/auto/declarative/visual/qdeclarativeflickable/flickable-vertical.qml
@@ -0,0 +1,91 @@
+import Qt 4.6
+
+Rectangle {
+ color: "lightSteelBlue"
+ width: 300; height: 600
+
+ ListModel {
+ id: list
+ ListElement { dayColor: "steelblue" }
+ ListElement { dayColor: "blue" }
+ ListElement { dayColor: "yellow" }
+ ListElement { dayColor: "purple" }
+ ListElement { dayColor: "red" }
+ ListElement { dayColor: "green" }
+ ListElement { dayColor: "orange" }
+ }
+
+ flickable {
+ id: flick
+ height: parent.height-50
+ width: parent.width; contentHeight: column.height
+
+ Column {
+ id: column
+ Repeater {
+ model: list
+ Rectangle { width: 300; height: 200; color: mr.pressed ? "black" : dayColor
+ MouseArea {
+ id: mr
+ anchors.fill: parent
+ }
+ }
+ }
+ }
+ clip: true
+ reportedVelocitySmoothing: 1000
+ }
+ Rectangle {
+ radius: 3
+ x: flick.width-8
+ width: 8
+ y: flick.visibleArea.yPosition * flick.height
+ height: flick.visibleArea.heightRatio * flick.height
+ }
+
+ // click to toggle interactive flag
+ Rectangle {
+ width: 64
+ height: 48
+ y: parent.height - 50
+ color: "red"
+ MouseArea {
+ anchors.fill: parent
+ onClicked: flick.interactive = flick.interactive ? false : true
+ }
+ }
+
+ // click to toggle click delay
+ Rectangle {
+ width: 64
+ height: 48
+ x: 66
+ y: parent.height - 50
+ color: "green"
+ MouseArea {
+ anchors.fill: parent
+ onClicked: flick.pressDelay = flick.pressDelay > 0 ? 0 : 500
+ }
+ }
+
+ // click to toggle overshoot
+ Rectangle {
+ width: 64
+ height: 48
+ x: 130
+ y: parent.height - 50
+ color: "yellow"
+ MouseArea {
+ anchors.fill: parent
+ onClicked: flick.overShoot = flick.overShoot > 0 ? 0 : 30
+ }
+ }
+
+ Rectangle {
+ width: Math.abs(flick.verticalVelocity)/100
+ height: 50
+ x: 200
+ y: parent.height - 50
+ color: blue
+ }
+}
diff --git a/tests/auto/declarative/visual/qmlgraphicsflipable/data/test-flipable.0.png b/tests/auto/declarative/visual/qdeclarativeflipable/data/test-flipable.0.png
index 53a8b42..53a8b42 100644
--- a/tests/auto/declarative/visual/qmlgraphicsflipable/data/test-flipable.0.png
+++ b/tests/auto/declarative/visual/qdeclarativeflipable/data/test-flipable.0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsflipable/data/test-flipable.1.png b/tests/auto/declarative/visual/qdeclarativeflipable/data/test-flipable.1.png
index b7efe8c..b7efe8c 100644
--- a/tests/auto/declarative/visual/qmlgraphicsflipable/data/test-flipable.1.png
+++ b/tests/auto/declarative/visual/qdeclarativeflipable/data/test-flipable.1.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsflipable/data/test-flipable.2.png b/tests/auto/declarative/visual/qdeclarativeflipable/data/test-flipable.2.png
index aa6d147..aa6d147 100644
--- a/tests/auto/declarative/visual/qmlgraphicsflipable/data/test-flipable.2.png
+++ b/tests/auto/declarative/visual/qdeclarativeflipable/data/test-flipable.2.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsflipable/data/test-flipable.3.png b/tests/auto/declarative/visual/qdeclarativeflipable/data/test-flipable.3.png
index 9d39713..9d39713 100644
--- a/tests/auto/declarative/visual/qmlgraphicsflipable/data/test-flipable.3.png
+++ b/tests/auto/declarative/visual/qdeclarativeflipable/data/test-flipable.3.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsflipable/data/test-flipable.4.png b/tests/auto/declarative/visual/qdeclarativeflipable/data/test-flipable.4.png
index 98e8817..98e8817 100644
--- a/tests/auto/declarative/visual/qmlgraphicsflipable/data/test-flipable.4.png
+++ b/tests/auto/declarative/visual/qdeclarativeflipable/data/test-flipable.4.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsflipable/data/test-flipable.5.png b/tests/auto/declarative/visual/qdeclarativeflipable/data/test-flipable.5.png
index a3f9d8f..a3f9d8f 100644
--- a/tests/auto/declarative/visual/qmlgraphicsflipable/data/test-flipable.5.png
+++ b/tests/auto/declarative/visual/qdeclarativeflipable/data/test-flipable.5.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsflipable/data/test-flipable.qml b/tests/auto/declarative/visual/qdeclarativeflipable/data/test-flipable.qml
index 520d9a2..520d9a2 100644
--- a/tests/auto/declarative/visual/qmlgraphicsflipable/data/test-flipable.qml
+++ b/tests/auto/declarative/visual/qdeclarativeflipable/data/test-flipable.qml
diff --git a/tests/auto/declarative/visual/qdeclarativeflipable/test-flipable.qml b/tests/auto/declarative/visual/qdeclarativeflipable/test-flipable.qml
new file mode 100644
index 0000000..a27aa6e
--- /dev/null
+++ b/tests/auto/declarative/visual/qdeclarativeflipable/test-flipable.qml
@@ -0,0 +1,79 @@
+import Qt 4.6
+
+Rectangle {
+ width: 400; height: 240
+ color: "white"
+
+ Timer {
+ interval: 3000; running: true; repeat: true; triggeredOnStart: true
+ onTriggered: {
+ if (flipable.state == '') flipable.state = 'back'; else flipable.state = ''
+ if (flipable2.state == '') flipable2.state = 'back'; else flipable2.state = ''
+ }
+ }
+
+ Flipable {
+ id: flipable
+ width: 200; height: 200
+
+ transform: Rotation {
+ id: rotation; angle: 0
+ origin.x: 100; origin.y: 100
+ axis.x: 0; axis.y: 1; axis.z: 0
+ }
+
+ front: Rectangle {
+ color: "steelblue"; width: 200; height: 200
+ }
+
+ back: Rectangle {
+ color: "deeppink"; width: 200; height: 200
+ }
+
+ states: State {
+ name: "back"
+ PropertyChanges { target: rotation; angle: 180 }
+ }
+
+ transitions: Transition {
+ NumberAnimation { easing.type: "InOutQuad"; properties: "angle"; duration: 3000 }
+ }
+ }
+
+ Flipable {
+ id: flipable2
+ x: 200; width: 200; height: 200
+
+ transform: Rotation {
+ id: rotation2; angle: 0
+ origin.x: 100; origin.y: 100
+ axis.x: 1; axis.z: 0
+ }
+
+ front: Rectangle {
+ color: "deeppink"; width: 200; height: 200
+ }
+
+ back: Rectangle {
+ color: "steelblue"; width: 200; height: 200
+ }
+
+ states: State {
+ name: "back"
+ PropertyChanges { target: rotation2; angle: 180 }
+ }
+
+ transitions: Transition {
+ NumberAnimation { easing.type: "InOutQuad"; properties: "angle"; duration: 3000 }
+ }
+ }
+
+ Rectangle {
+ x: 25; width: 150; y: 210; height: 20; color: "black"
+ visible: flipable.side == Flipable.Front
+ }
+ Rectangle {
+ x: 225; width: 150; y: 210; height: 20; color: "black"
+ visible: flipable2.side == Flipable.Back
+ }
+}
diff --git a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview.0.png b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview.0.png
index 6c82777..6c82777 100644
--- a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview.0.png
+++ b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview.0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview.1.png b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview.1.png
index 07b1f7c..07b1f7c 100644
--- a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview.1.png
+++ b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview.1.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview.2.png b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview.2.png
index f2f08c0..f2f08c0 100644
--- a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview.2.png
+++ b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview.2.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview.3.png b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview.3.png
index 08649f9..08649f9 100644
--- a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview.3.png
+++ b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview.3.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview.4.png b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview.4.png
index f9c2f17..f9c2f17 100644
--- a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview.4.png
+++ b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview.4.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview.5.png b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview.5.png
index 52ec0bd..52ec0bd 100644
--- a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview.5.png
+++ b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview.5.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview.6.png b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview.6.png
index 3fe25be..3fe25be 100644
--- a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview.6.png
+++ b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview.6.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview.7.png b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview.7.png
index 4cc12a6..4cc12a6 100644
--- a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview.7.png
+++ b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview.7.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview.8.png b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview.8.png
index 2267f23..2267f23 100644
--- a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview.8.png
+++ b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview.8.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview.9.png b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview.9.png
index 6c82777..6c82777 100644
--- a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview.9.png
+++ b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview.9.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview.qml b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview.qml
index c7ac52d..c7ac52d 100644
--- a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview.qml
+++ b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview2.0.png b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview2.0.png
index 3021d58..3021d58 100644
--- a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview2.0.png
+++ b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview2.0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview2.1.png b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview2.1.png
index baeb1a6..baeb1a6 100644
--- a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview2.1.png
+++ b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview2.1.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview2.10.png b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview2.10.png
index b0486e5..b0486e5 100644
--- a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview2.10.png
+++ b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview2.10.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview2.2.png b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview2.2.png
index 2d0c731..2d0c731 100644
--- a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview2.2.png
+++ b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview2.2.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview2.3.png b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview2.3.png
index af9ed05..af9ed05 100644
--- a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview2.3.png
+++ b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview2.3.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview2.4.png b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview2.4.png
index 0b0945d..0b0945d 100644
--- a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview2.4.png
+++ b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview2.4.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview2.5.png b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview2.5.png
index 618ae0c..618ae0c 100644
--- a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview2.5.png
+++ b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview2.5.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview2.6.png b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview2.6.png
index fc31262..fc31262 100644
--- a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview2.6.png
+++ b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview2.6.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview2.7.png b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview2.7.png
index 22291ac..22291ac 100644
--- a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview2.7.png
+++ b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview2.7.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview2.8.png b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview2.8.png
index 3021d58..3021d58 100644
--- a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview2.8.png
+++ b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview2.8.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview2.9.png b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview2.9.png
index 2f2f5b9..2f2f5b9 100644
--- a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview2.9.png
+++ b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview2.9.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview2.qml b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview2.qml
index fb5f1fb..fb5f1fb 100644
--- a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview2.qml
+++ b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview2.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicsgridview/gridview.qml b/tests/auto/declarative/visual/qdeclarativegridview/gridview.qml
index f8782a5..f8782a5 100644
--- a/tests/auto/declarative/visual/qmlgraphicsgridview/gridview.qml
+++ b/tests/auto/declarative/visual/qdeclarativegridview/gridview.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicsgridview/gridview2.qml b/tests/auto/declarative/visual/qdeclarativegridview/gridview2.qml
index 81d06cf..81d06cf 100644
--- a/tests/auto/declarative/visual/qmlgraphicsgridview/gridview2.qml
+++ b/tests/auto/declarative/visual/qdeclarativegridview/gridview2.qml
diff --git a/tests/auto/declarative/visual/qmlmouseregion/data/drag.0.png b/tests/auto/declarative/visual/qdeclarativemouseregion/data/drag.0.png
index cf36d60..cf36d60 100644
--- a/tests/auto/declarative/visual/qmlmouseregion/data/drag.0.png
+++ b/tests/auto/declarative/visual/qdeclarativemouseregion/data/drag.0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlmouseregion/data/drag.1.png b/tests/auto/declarative/visual/qdeclarativemouseregion/data/drag.1.png
index 6069df8..6069df8 100644
--- a/tests/auto/declarative/visual/qmlmouseregion/data/drag.1.png
+++ b/tests/auto/declarative/visual/qdeclarativemouseregion/data/drag.1.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlmouseregion/data/drag.2.png b/tests/auto/declarative/visual/qdeclarativemouseregion/data/drag.2.png
index b8bd5f3..b8bd5f3 100644
--- a/tests/auto/declarative/visual/qmlmouseregion/data/drag.2.png
+++ b/tests/auto/declarative/visual/qdeclarativemouseregion/data/drag.2.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlmouseregion/data/drag.3.png b/tests/auto/declarative/visual/qdeclarativemouseregion/data/drag.3.png
index cf36d60..cf36d60 100644
--- a/tests/auto/declarative/visual/qmlmouseregion/data/drag.3.png
+++ b/tests/auto/declarative/visual/qdeclarativemouseregion/data/drag.3.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlmouseregion/data/drag.4.png b/tests/auto/declarative/visual/qdeclarativemouseregion/data/drag.4.png
index 831d6b4..831d6b4 100644
--- a/tests/auto/declarative/visual/qmlmouseregion/data/drag.4.png
+++ b/tests/auto/declarative/visual/qdeclarativemouseregion/data/drag.4.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlmouseregion/data/drag.5.png b/tests/auto/declarative/visual/qdeclarativemouseregion/data/drag.5.png
index f7079dc..f7079dc 100644
--- a/tests/auto/declarative/visual/qmlmouseregion/data/drag.5.png
+++ b/tests/auto/declarative/visual/qdeclarativemouseregion/data/drag.5.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlmouseregion/data/drag.6.png b/tests/auto/declarative/visual/qdeclarativemouseregion/data/drag.6.png
index a5f4451..a5f4451 100644
--- a/tests/auto/declarative/visual/qmlmouseregion/data/drag.6.png
+++ b/tests/auto/declarative/visual/qdeclarativemouseregion/data/drag.6.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlmouseregion/data/drag.7.png b/tests/auto/declarative/visual/qdeclarativemouseregion/data/drag.7.png
index e1261d0..e1261d0 100644
--- a/tests/auto/declarative/visual/qmlmouseregion/data/drag.7.png
+++ b/tests/auto/declarative/visual/qdeclarativemouseregion/data/drag.7.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlmouseregion/data/drag.8.png b/tests/auto/declarative/visual/qdeclarativemouseregion/data/drag.8.png
index 653905e..653905e 100644
--- a/tests/auto/declarative/visual/qmlmouseregion/data/drag.8.png
+++ b/tests/auto/declarative/visual/qdeclarativemouseregion/data/drag.8.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlmouseregion/data/drag.qml b/tests/auto/declarative/visual/qdeclarativemouseregion/data/drag.qml
index 5a131e9..5a131e9 100644
--- a/tests/auto/declarative/visual/qmlmouseregion/data/drag.qml
+++ b/tests/auto/declarative/visual/qdeclarativemouseregion/data/drag.qml
diff --git a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.0.png b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.0.png
index c249c21..c249c21 100644
--- a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.0.png
+++ b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.1.png b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.1.png
index a96bf1b..a96bf1b 100644
--- a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.1.png
+++ b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.1.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.10.png b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.10.png
index 7420ca7..7420ca7 100644
--- a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.10.png
+++ b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.10.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.11.png b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.11.png
index 7420ca7..7420ca7 100644
--- a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.11.png
+++ b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.11.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.12.png b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.12.png
index 7420ca7..7420ca7 100644
--- a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.12.png
+++ b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.12.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.13.png b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.13.png
index 7420ca7..7420ca7 100644
--- a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.13.png
+++ b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.13.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.14.png b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.14.png
index 7420ca7..7420ca7 100644
--- a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.14.png
+++ b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.14.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.15.png b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.15.png
index e797cc9..e797cc9 100644
--- a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.15.png
+++ b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.15.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.16.png b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.16.png
index 7951309..7951309 100644
--- a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.16.png
+++ b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.16.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.17.png b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.17.png
index 7951309..7951309 100644
--- a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.17.png
+++ b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.17.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.18.png b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.18.png
index 7951309..7951309 100644
--- a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.18.png
+++ b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.18.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.19.png b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.19.png
index 7951309..7951309 100644
--- a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.19.png
+++ b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.19.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.2.png b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.2.png
index a96bf1b..a96bf1b 100644
--- a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.2.png
+++ b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.2.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.20.png b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.20.png
index 7951309..7951309 100644
--- a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.20.png
+++ b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.20.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.21.png b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.21.png
index 7951309..7951309 100644
--- a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.21.png
+++ b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.21.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.22.png b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.22.png
index 7951309..7951309 100644
--- a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.22.png
+++ b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.22.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.3.png b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.3.png
index a96bf1b..a96bf1b 100644
--- a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.3.png
+++ b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.3.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.4.png b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.4.png
index 1fe365a..1fe365a 100644
--- a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.4.png
+++ b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.4.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.5.png b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.5.png
index 1fe365a..1fe365a 100644
--- a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.5.png
+++ b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.5.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.6.png b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.6.png
index 1fe365a..1fe365a 100644
--- a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.6.png
+++ b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.6.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.7.png b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.7.png
index 1fe365a..1fe365a 100644
--- a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.7.png
+++ b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.7.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.8.png b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.8.png
index 7420ca7..7420ca7 100644
--- a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.8.png
+++ b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.8.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.9.png b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.9.png
index 7420ca7..7420ca7 100644
--- a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.9.png
+++ b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.9.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.qml b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.qml
index cc374fd..cc374fd 100644
--- a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.qml
+++ b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.qml
diff --git a/tests/auto/declarative/visual/qmlmouseregion/drag.qml b/tests/auto/declarative/visual/qdeclarativemouseregion/drag.qml
index dbb2a24..dbb2a24 100644
--- a/tests/auto/declarative/visual/qmlmouseregion/drag.qml
+++ b/tests/auto/declarative/visual/qdeclarativemouseregion/drag.qml
diff --git a/tests/auto/declarative/visual/qmlmouseregion/mouseregion.qml b/tests/auto/declarative/visual/qdeclarativemouseregion/mouseregion.qml
index 3c722d0..3c722d0 100644
--- a/tests/auto/declarative/visual/qmlmouseregion/mouseregion.qml
+++ b/tests/auto/declarative/visual/qdeclarativemouseregion/mouseregion.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicsparticles/data/particles.0.png b/tests/auto/declarative/visual/qdeclarativeparticles/data/particles.0.png
index 7321d95..7321d95 100644
--- a/tests/auto/declarative/visual/qmlgraphicsparticles/data/particles.0.png
+++ b/tests/auto/declarative/visual/qdeclarativeparticles/data/particles.0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsparticles/data/particles.1.png b/tests/auto/declarative/visual/qdeclarativeparticles/data/particles.1.png
index 49d2a5a..49d2a5a 100644
--- a/tests/auto/declarative/visual/qmlgraphicsparticles/data/particles.1.png
+++ b/tests/auto/declarative/visual/qdeclarativeparticles/data/particles.1.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsparticles/data/particles.2.png b/tests/auto/declarative/visual/qdeclarativeparticles/data/particles.2.png
index 6fe14b7..6fe14b7 100644
--- a/tests/auto/declarative/visual/qmlgraphicsparticles/data/particles.2.png
+++ b/tests/auto/declarative/visual/qdeclarativeparticles/data/particles.2.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsparticles/data/particles.qml b/tests/auto/declarative/visual/qdeclarativeparticles/data/particles.qml
index d766dc6..d766dc6 100644
--- a/tests/auto/declarative/visual/qmlgraphicsparticles/data/particles.qml
+++ b/tests/auto/declarative/visual/qdeclarativeparticles/data/particles.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicsparticles/particles.qml b/tests/auto/declarative/visual/qdeclarativeparticles/particles.qml
index 2d481c9..2d481c9 100644
--- a/tests/auto/declarative/visual/qmlgraphicsparticles/particles.qml
+++ b/tests/auto/declarative/visual/qdeclarativeparticles/particles.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicsparticles/star.png b/tests/auto/declarative/visual/qdeclarativeparticles/star.png
index defbde5..defbde5 100644
--- a/tests/auto/declarative/visual/qmlgraphicsparticles/star.png
+++ b/tests/auto/declarative/visual/qdeclarativeparticles/star.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview-2.0.png b/tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview-2.0.png
index 18c8a9e..18c8a9e 100644
--- a/tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview-2.0.png
+++ b/tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview-2.0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview-2.1.png b/tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview-2.1.png
index e86acb4..e86acb4 100644
--- a/tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview-2.1.png
+++ b/tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview-2.1.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview-2.2.png b/tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview-2.2.png
index 17990b7..17990b7 100644
--- a/tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview-2.2.png
+++ b/tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview-2.2.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview-2.3.png b/tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview-2.3.png
index 18c8a9e..18c8a9e 100644
--- a/tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview-2.3.png
+++ b/tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview-2.3.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview-2.4.png b/tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview-2.4.png
index 18c8a9e..18c8a9e 100644
--- a/tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview-2.4.png
+++ b/tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview-2.4.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview-2.5.png b/tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview-2.5.png
index 8636f8f..8636f8f 100644
--- a/tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview-2.5.png
+++ b/tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview-2.5.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview-2.6.png b/tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview-2.6.png
index fa7c4b6..fa7c4b6 100644
--- a/tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview-2.6.png
+++ b/tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview-2.6.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview-2.qml b/tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview-2.qml
index b8ff925..b8ff925 100644
--- a/tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview-2.qml
+++ b/tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview-2.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview.0.png b/tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview.0.png
index 442ba9f..442ba9f 100644
--- a/tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview.0.png
+++ b/tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview.0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview.1.png b/tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview.1.png
index a9ff20f..a9ff20f 100644
--- a/tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview.1.png
+++ b/tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview.1.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview.2.png b/tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview.2.png
index 157bb99..157bb99 100644
--- a/tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview.2.png
+++ b/tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview.2.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview.3.png b/tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview.3.png
index 8c49acb..8c49acb 100644
--- a/tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview.3.png
+++ b/tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview.3.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview.4.png b/tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview.4.png
index eb2bf54..eb2bf54 100644
--- a/tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview.4.png
+++ b/tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview.4.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview.qml b/tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview.qml
index 8cff5c6..8cff5c6 100644
--- a/tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview.qml
+++ b/tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicspathview/test-pathview-2.qml b/tests/auto/declarative/visual/qdeclarativepathview/test-pathview-2.qml
index c6d71d5..c6d71d5 100644
--- a/tests/auto/declarative/visual/qmlgraphicspathview/test-pathview-2.qml
+++ b/tests/auto/declarative/visual/qdeclarativepathview/test-pathview-2.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicspathview/test-pathview.qml b/tests/auto/declarative/visual/qdeclarativepathview/test-pathview.qml
index 0adfa02..0adfa02 100644
--- a/tests/auto/declarative/visual/qmlgraphicspathview/test-pathview.qml
+++ b/tests/auto/declarative/visual/qdeclarativepathview/test-pathview.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicspositioners/data/dynamic.0.png b/tests/auto/declarative/visual/qdeclarativepositioners/data/dynamic.0.png
index f474afe..f474afe 100644
--- a/tests/auto/declarative/visual/qmlgraphicspositioners/data/dynamic.0.png
+++ b/tests/auto/declarative/visual/qdeclarativepositioners/data/dynamic.0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicspositioners/data/dynamic.1.png b/tests/auto/declarative/visual/qdeclarativepositioners/data/dynamic.1.png
index 8b7ae74..8b7ae74 100644
--- a/tests/auto/declarative/visual/qmlgraphicspositioners/data/dynamic.1.png
+++ b/tests/auto/declarative/visual/qdeclarativepositioners/data/dynamic.1.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicspositioners/data/dynamic.2.png b/tests/auto/declarative/visual/qdeclarativepositioners/data/dynamic.2.png
index 9088bb4..9088bb4 100644
--- a/tests/auto/declarative/visual/qmlgraphicspositioners/data/dynamic.2.png
+++ b/tests/auto/declarative/visual/qdeclarativepositioners/data/dynamic.2.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicspositioners/data/dynamic.3.png b/tests/auto/declarative/visual/qdeclarativepositioners/data/dynamic.3.png
index 18cd429..18cd429 100644
--- a/tests/auto/declarative/visual/qmlgraphicspositioners/data/dynamic.3.png
+++ b/tests/auto/declarative/visual/qdeclarativepositioners/data/dynamic.3.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicspositioners/data/dynamic.4.png b/tests/auto/declarative/visual/qdeclarativepositioners/data/dynamic.4.png
index 739afc1..739afc1 100644
--- a/tests/auto/declarative/visual/qmlgraphicspositioners/data/dynamic.4.png
+++ b/tests/auto/declarative/visual/qdeclarativepositioners/data/dynamic.4.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicspositioners/data/dynamic.5.png b/tests/auto/declarative/visual/qdeclarativepositioners/data/dynamic.5.png
index 93f0682..93f0682 100644
--- a/tests/auto/declarative/visual/qmlgraphicspositioners/data/dynamic.5.png
+++ b/tests/auto/declarative/visual/qdeclarativepositioners/data/dynamic.5.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicspositioners/data/dynamic.qml b/tests/auto/declarative/visual/qdeclarativepositioners/data/dynamic.qml
index 7091bb3..7091bb3 100644
--- a/tests/auto/declarative/visual/qmlgraphicspositioners/data/dynamic.qml
+++ b/tests/auto/declarative/visual/qdeclarativepositioners/data/dynamic.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicspositioners/data/repeater.0.png b/tests/auto/declarative/visual/qdeclarativepositioners/data/repeater.0.png
index f7018fd..f7018fd 100644
--- a/tests/auto/declarative/visual/qmlgraphicspositioners/data/repeater.0.png
+++ b/tests/auto/declarative/visual/qdeclarativepositioners/data/repeater.0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicspositioners/data/repeater.qml b/tests/auto/declarative/visual/qdeclarativepositioners/data/repeater.qml
index 1eb115d..1eb115d 100644
--- a/tests/auto/declarative/visual/qmlgraphicspositioners/data/repeater.qml
+++ b/tests/auto/declarative/visual/qdeclarativepositioners/data/repeater.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicspositioners/dynamic.qml b/tests/auto/declarative/visual/qdeclarativepositioners/dynamic.qml
index f45e9a4..f45e9a4 100644
--- a/tests/auto/declarative/visual/qmlgraphicspositioners/dynamic.qml
+++ b/tests/auto/declarative/visual/qdeclarativepositioners/dynamic.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicspositioners/repeater.qml b/tests/auto/declarative/visual/qdeclarativepositioners/repeater.qml
index ff60365..ff60365 100644
--- a/tests/auto/declarative/visual/qmlgraphicspositioners/repeater.qml
+++ b/tests/auto/declarative/visual/qdeclarativepositioners/repeater.qml
diff --git a/tests/auto/declarative/visual/qmlspringfollow/clock.qml b/tests/auto/declarative/visual/qdeclarativespringfollow/clock.qml
index 04bbabc..04bbabc 100644
--- a/tests/auto/declarative/visual/qmlspringfollow/clock.qml
+++ b/tests/auto/declarative/visual/qdeclarativespringfollow/clock.qml
diff --git a/tests/auto/declarative/visual/qmlspringfollow/content/background.png b/tests/auto/declarative/visual/qdeclarativespringfollow/content/background.png
index a885950..a885950 100644
--- a/tests/auto/declarative/visual/qmlspringfollow/content/background.png
+++ b/tests/auto/declarative/visual/qdeclarativespringfollow/content/background.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlspringfollow/content/center.png b/tests/auto/declarative/visual/qdeclarativespringfollow/content/center.png
index 7fbd802..7fbd802 100755
--- a/tests/auto/declarative/visual/qmlspringfollow/content/center.png
+++ b/tests/auto/declarative/visual/qdeclarativespringfollow/content/center.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlspringfollow/content/clock.png b/tests/auto/declarative/visual/qdeclarativespringfollow/content/clock.png
index 462edac..462edac 100755
--- a/tests/auto/declarative/visual/qmlspringfollow/content/clock.png
+++ b/tests/auto/declarative/visual/qdeclarativespringfollow/content/clock.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlspringfollow/content/hour.png b/tests/auto/declarative/visual/qdeclarativespringfollow/content/hour.png
index f8061a1..f8061a1 100755
--- a/tests/auto/declarative/visual/qmlspringfollow/content/hour.png
+++ b/tests/auto/declarative/visual/qdeclarativespringfollow/content/hour.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlspringfollow/content/minute.png b/tests/auto/declarative/visual/qdeclarativespringfollow/content/minute.png
index 1297ec7..1297ec7 100755
--- a/tests/auto/declarative/visual/qmlspringfollow/content/minute.png
+++ b/tests/auto/declarative/visual/qdeclarativespringfollow/content/minute.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlspringfollow/content/second.png b/tests/auto/declarative/visual/qdeclarativespringfollow/content/second.png
index 4aa9fb5..4aa9fb5 100755
--- a/tests/auto/declarative/visual/qmlspringfollow/content/second.png
+++ b/tests/auto/declarative/visual/qdeclarativespringfollow/content/second.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlspringfollow/data/clock.0.png b/tests/auto/declarative/visual/qdeclarativespringfollow/data/clock.0.png
index baf1d45..baf1d45 100644
--- a/tests/auto/declarative/visual/qmlspringfollow/data/clock.0.png
+++ b/tests/auto/declarative/visual/qdeclarativespringfollow/data/clock.0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlspringfollow/data/clock.1.png b/tests/auto/declarative/visual/qdeclarativespringfollow/data/clock.1.png
index 932f63f..932f63f 100644
--- a/tests/auto/declarative/visual/qmlspringfollow/data/clock.1.png
+++ b/tests/auto/declarative/visual/qdeclarativespringfollow/data/clock.1.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlspringfollow/data/clock.2.png b/tests/auto/declarative/visual/qdeclarativespringfollow/data/clock.2.png
index a5cb437..a5cb437 100644
--- a/tests/auto/declarative/visual/qmlspringfollow/data/clock.2.png
+++ b/tests/auto/declarative/visual/qdeclarativespringfollow/data/clock.2.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlspringfollow/data/clock.3.png b/tests/auto/declarative/visual/qdeclarativespringfollow/data/clock.3.png
index 62e895c..62e895c 100644
--- a/tests/auto/declarative/visual/qmlspringfollow/data/clock.3.png
+++ b/tests/auto/declarative/visual/qdeclarativespringfollow/data/clock.3.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlspringfollow/data/clock.qml b/tests/auto/declarative/visual/qdeclarativespringfollow/data/clock.qml
index ffc6a5e..ffc6a5e 100644
--- a/tests/auto/declarative/visual/qmlspringfollow/data/clock.qml
+++ b/tests/auto/declarative/visual/qdeclarativespringfollow/data/clock.qml
diff --git a/tests/auto/declarative/visual/qmlspringfollow/data/follow.0.png b/tests/auto/declarative/visual/qdeclarativespringfollow/data/follow.0.png
index 3f42e75..3f42e75 100644
--- a/tests/auto/declarative/visual/qmlspringfollow/data/follow.0.png
+++ b/tests/auto/declarative/visual/qdeclarativespringfollow/data/follow.0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlspringfollow/data/follow.1.png b/tests/auto/declarative/visual/qdeclarativespringfollow/data/follow.1.png
index d661df6..d661df6 100644
--- a/tests/auto/declarative/visual/qmlspringfollow/data/follow.1.png
+++ b/tests/auto/declarative/visual/qdeclarativespringfollow/data/follow.1.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlspringfollow/data/follow.10.png b/tests/auto/declarative/visual/qdeclarativespringfollow/data/follow.10.png
index e8c96e1..e8c96e1 100644
--- a/tests/auto/declarative/visual/qmlspringfollow/data/follow.10.png
+++ b/tests/auto/declarative/visual/qdeclarativespringfollow/data/follow.10.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlspringfollow/data/follow.2.png b/tests/auto/declarative/visual/qdeclarativespringfollow/data/follow.2.png
index 35bfa43..35bfa43 100644
--- a/tests/auto/declarative/visual/qmlspringfollow/data/follow.2.png
+++ b/tests/auto/declarative/visual/qdeclarativespringfollow/data/follow.2.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlspringfollow/data/follow.3.png b/tests/auto/declarative/visual/qdeclarativespringfollow/data/follow.3.png
index 74141cf..74141cf 100644
--- a/tests/auto/declarative/visual/qmlspringfollow/data/follow.3.png
+++ b/tests/auto/declarative/visual/qdeclarativespringfollow/data/follow.3.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlspringfollow/data/follow.4.png b/tests/auto/declarative/visual/qdeclarativespringfollow/data/follow.4.png
index 9544054..9544054 100644
--- a/tests/auto/declarative/visual/qmlspringfollow/data/follow.4.png
+++ b/tests/auto/declarative/visual/qdeclarativespringfollow/data/follow.4.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlspringfollow/data/follow.5.png b/tests/auto/declarative/visual/qdeclarativespringfollow/data/follow.5.png
index 4b02c79..4b02c79 100644
--- a/tests/auto/declarative/visual/qmlspringfollow/data/follow.5.png
+++ b/tests/auto/declarative/visual/qdeclarativespringfollow/data/follow.5.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlspringfollow/data/follow.6.png b/tests/auto/declarative/visual/qdeclarativespringfollow/data/follow.6.png
index 8ea8345..8ea8345 100644
--- a/tests/auto/declarative/visual/qmlspringfollow/data/follow.6.png
+++ b/tests/auto/declarative/visual/qdeclarativespringfollow/data/follow.6.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlspringfollow/data/follow.7.png b/tests/auto/declarative/visual/qdeclarativespringfollow/data/follow.7.png
index 76a73e8..76a73e8 100644
--- a/tests/auto/declarative/visual/qmlspringfollow/data/follow.7.png
+++ b/tests/auto/declarative/visual/qdeclarativespringfollow/data/follow.7.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlspringfollow/data/follow.8.png b/tests/auto/declarative/visual/qdeclarativespringfollow/data/follow.8.png
index 8824940..8824940 100644
--- a/tests/auto/declarative/visual/qmlspringfollow/data/follow.8.png
+++ b/tests/auto/declarative/visual/qdeclarativespringfollow/data/follow.8.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlspringfollow/data/follow.9.png b/tests/auto/declarative/visual/qdeclarativespringfollow/data/follow.9.png
index f954cc5..f954cc5 100644
--- a/tests/auto/declarative/visual/qmlspringfollow/data/follow.9.png
+++ b/tests/auto/declarative/visual/qdeclarativespringfollow/data/follow.9.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlspringfollow/data/follow.qml b/tests/auto/declarative/visual/qdeclarativespringfollow/data/follow.qml
index fec5428..fec5428 100644
--- a/tests/auto/declarative/visual/qmlspringfollow/data/follow.qml
+++ b/tests/auto/declarative/visual/qdeclarativespringfollow/data/follow.qml
diff --git a/tests/auto/declarative/visual/qdeclarativespringfollow/follow.qml b/tests/auto/declarative/visual/qdeclarativespringfollow/follow.qml
new file mode 100644
index 0000000..62503e4
--- /dev/null
+++ b/tests/auto/declarative/visual/qdeclarativespringfollow/follow.qml
@@ -0,0 +1,71 @@
+import Qt 4.6
+
+Rectangle {
+ color: "#ffffff"
+ width: 320; height: 240
+ Rectangle {
+ id: rect
+ color: "#00ff00"
+ y: 200; width: 60; height: 20
+ y: SequentialAnimation {
+ repeat: true
+ NumberAnimation {
+ to: 20; duration: 500
+ easing.type: "InOutQuad"
+ }
+ NumberAnimation {
+ to: 200; duration: 2000
+ easing.type: "OutBounce"
+ }
+ PauseAnimation { duration: 1000 }
+ }
+ }
+
+ // Velocity
+ Rectangle {
+ color: "#ff0000"
+ x: rect.width; width: rect.width; height: 20
+ y: 200
+ y: SpringFollow { source: rect.y; velocity: 200 }
+ }
+
+ // Spring
+ Rectangle {
+ color: "#ff0000"
+ x: rect.width * 2; width: rect.width/2; height: 20
+ y: 200
+ y: SpringFollow { source: rect.y; spring: 1.0; damping: 0.2 }
+ }
+ Rectangle {
+ color: "#880000"
+ x: rect.width * 2.5; width: rect.width/2; height: 20
+ y: 200
+ y: SpringFollow { source: rect.y; spring: 1.0; damping: 0.2; mass: 3.0 } // "heavier" object
+ }
+
+ // Follow mouse
+ MouseArea {
+ id: mouseRegion
+ anchors.fill: parent
+ Rectangle {
+ id: ball
+ width: 20; height: 20
+ radius: 10
+ color: "#0000ff"
+ x: SpringFollow { id: f1; source: mouseRegion.mouseX-10; spring: 1.0; damping: 0.05; epsilon: 0.25 }
+ y: SpringFollow { id: f2; source: mouseRegion.mouseY-10; spring: 1.0; damping: 0.05; epsilon: 0.25 }
+ states: [
+ State {
+ name: "following"
+ when: !f1.inSync || !f2.inSync
+ PropertyChanges { target: ball; color: "#ff0000" }
+ }
+ ]
+ transitions: [
+ Transition {
+ ColorAnimation { duration: 200 }
+ }
+ ]
+ }
+ }
+}
diff --git a/tests/auto/declarative/visual/qmlgraphicstext/baseline/data/parentanchor.qml b/tests/auto/declarative/visual/qdeclarativetext/baseline/data-X11/parentanchor.qml
index 56d616e..56d616e 100644
--- a/tests/auto/declarative/visual/qmlgraphicstext/baseline/data/parentanchor.qml
+++ b/tests/auto/declarative/visual/qdeclarativetext/baseline/data-X11/parentanchor.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicstext/baseline/data-X11/parentanchor.qml b/tests/auto/declarative/visual/qdeclarativetext/baseline/data/parentanchor.qml
index 56d616e..56d616e 100644
--- a/tests/auto/declarative/visual/qmlgraphicstext/baseline/data-X11/parentanchor.qml
+++ b/tests/auto/declarative/visual/qdeclarativetext/baseline/data/parentanchor.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicstext/baseline/parentanchor.qml b/tests/auto/declarative/visual/qdeclarativetext/baseline/parentanchor.qml
index 80f0f03..80f0f03 100644
--- a/tests/auto/declarative/visual/qmlgraphicstext/baseline/parentanchor.qml
+++ b/tests/auto/declarative/visual/qdeclarativetext/baseline/parentanchor.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicstext/elide/data-MAC/elide.0.png b/tests/auto/declarative/visual/qdeclarativetext/elide/data-MAC/elide.0.png
index eea3362..eea3362 100644
--- a/tests/auto/declarative/visual/qmlgraphicstext/elide/data-MAC/elide.0.png
+++ b/tests/auto/declarative/visual/qdeclarativetext/elide/data-MAC/elide.0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstext/elide/data-MAC/elide.qml b/tests/auto/declarative/visual/qdeclarativetext/elide/data-MAC/elide.qml
index 1ccede4..1ccede4 100644
--- a/tests/auto/declarative/visual/qmlgraphicstext/elide/data-MAC/elide.qml
+++ b/tests/auto/declarative/visual/qdeclarativetext/elide/data-MAC/elide.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicstext/elide/data/elide2.0.png b/tests/auto/declarative/visual/qdeclarativetext/elide/data-MAC/elide2.0.png
index 3dfade5..3dfade5 100644
--- a/tests/auto/declarative/visual/qmlgraphicstext/elide/data/elide2.0.png
+++ b/tests/auto/declarative/visual/qdeclarativetext/elide/data-MAC/elide2.0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstext/elide/data/elide2.1.png b/tests/auto/declarative/visual/qdeclarativetext/elide/data-MAC/elide2.1.png
index 1ee2076..1ee2076 100644
--- a/tests/auto/declarative/visual/qmlgraphicstext/elide/data/elide2.1.png
+++ b/tests/auto/declarative/visual/qdeclarativetext/elide/data-MAC/elide2.1.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstext/elide/data/elide2.2.png b/tests/auto/declarative/visual/qdeclarativetext/elide/data-MAC/elide2.2.png
index ae680be..ae680be 100644
--- a/tests/auto/declarative/visual/qmlgraphicstext/elide/data/elide2.2.png
+++ b/tests/auto/declarative/visual/qdeclarativetext/elide/data-MAC/elide2.2.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstext/elide/data/elide2.3.png b/tests/auto/declarative/visual/qdeclarativetext/elide/data-MAC/elide2.3.png
index c2859be..c2859be 100644
--- a/tests/auto/declarative/visual/qmlgraphicstext/elide/data/elide2.3.png
+++ b/tests/auto/declarative/visual/qdeclarativetext/elide/data-MAC/elide2.3.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstext/elide/data-MAC/elide2.qml b/tests/auto/declarative/visual/qdeclarativetext/elide/data-MAC/elide2.qml
index 07ad236..07ad236 100644
--- a/tests/auto/declarative/visual/qmlgraphicstext/elide/data-MAC/elide2.qml
+++ b/tests/auto/declarative/visual/qdeclarativetext/elide/data-MAC/elide2.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicstext/elide/data-MAC/multilength.0.png b/tests/auto/declarative/visual/qdeclarativetext/elide/data-MAC/multilength.0.png
index 80549b4..80549b4 100644
--- a/tests/auto/declarative/visual/qmlgraphicstext/elide/data-MAC/multilength.0.png
+++ b/tests/auto/declarative/visual/qdeclarativetext/elide/data-MAC/multilength.0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstext/elide/data-MAC/multilength.qml b/tests/auto/declarative/visual/qdeclarativetext/elide/data-MAC/multilength.qml
index c2fd0d8..c2fd0d8 100644
--- a/tests/auto/declarative/visual/qmlgraphicstext/elide/data-MAC/multilength.qml
+++ b/tests/auto/declarative/visual/qdeclarativetext/elide/data-MAC/multilength.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicstext/elide/data-X11/elide.0.png b/tests/auto/declarative/visual/qdeclarativetext/elide/data-X11/elide.0.png
index 5631a46..5631a46 100644
--- a/tests/auto/declarative/visual/qmlgraphicstext/elide/data-X11/elide.0.png
+++ b/tests/auto/declarative/visual/qdeclarativetext/elide/data-X11/elide.0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstext/elide/data-X11/elide.qml b/tests/auto/declarative/visual/qdeclarativetext/elide/data-X11/elide.qml
index cfd832e..cfd832e 100644
--- a/tests/auto/declarative/visual/qmlgraphicstext/elide/data-X11/elide.qml
+++ b/tests/auto/declarative/visual/qdeclarativetext/elide/data-X11/elide.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicstext/elide/data-X11/multilength.0.png b/tests/auto/declarative/visual/qdeclarativetext/elide/data-X11/multilength.0.png
index 6e2b625..6e2b625 100644
--- a/tests/auto/declarative/visual/qmlgraphicstext/elide/data-X11/multilength.0.png
+++ b/tests/auto/declarative/visual/qdeclarativetext/elide/data-X11/multilength.0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstext/elide/data-X11/multilength.qml b/tests/auto/declarative/visual/qdeclarativetext/elide/data-X11/multilength.qml
index 0c06196..0c06196 100644
--- a/tests/auto/declarative/visual/qmlgraphicstext/elide/data-X11/multilength.qml
+++ b/tests/auto/declarative/visual/qdeclarativetext/elide/data-X11/multilength.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicstext/elide/data/elide.0.png b/tests/auto/declarative/visual/qdeclarativetext/elide/data/elide.0.png
index 1a8c89b..1a8c89b 100644
--- a/tests/auto/declarative/visual/qmlgraphicstext/elide/data/elide.0.png
+++ b/tests/auto/declarative/visual/qdeclarativetext/elide/data/elide.0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstext/elide/data/elide.qml b/tests/auto/declarative/visual/qdeclarativetext/elide/data/elide.qml
index 59f17f7..59f17f7 100644
--- a/tests/auto/declarative/visual/qmlgraphicstext/elide/data/elide.qml
+++ b/tests/auto/declarative/visual/qdeclarativetext/elide/data/elide.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicstext/elide/data-MAC/elide2.0.png b/tests/auto/declarative/visual/qdeclarativetext/elide/data/elide2.0.png
index 3dfade5..3dfade5 100644
--- a/tests/auto/declarative/visual/qmlgraphicstext/elide/data-MAC/elide2.0.png
+++ b/tests/auto/declarative/visual/qdeclarativetext/elide/data/elide2.0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstext/elide/data-MAC/elide2.1.png b/tests/auto/declarative/visual/qdeclarativetext/elide/data/elide2.1.png
index 1ee2076..1ee2076 100644
--- a/tests/auto/declarative/visual/qmlgraphicstext/elide/data-MAC/elide2.1.png
+++ b/tests/auto/declarative/visual/qdeclarativetext/elide/data/elide2.1.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstext/elide/data-MAC/elide2.2.png b/tests/auto/declarative/visual/qdeclarativetext/elide/data/elide2.2.png
index ae680be..ae680be 100644
--- a/tests/auto/declarative/visual/qmlgraphicstext/elide/data-MAC/elide2.2.png
+++ b/tests/auto/declarative/visual/qdeclarativetext/elide/data/elide2.2.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstext/elide/data-MAC/elide2.3.png b/tests/auto/declarative/visual/qdeclarativetext/elide/data/elide2.3.png
index c2859be..c2859be 100644
--- a/tests/auto/declarative/visual/qmlgraphicstext/elide/data-MAC/elide2.3.png
+++ b/tests/auto/declarative/visual/qdeclarativetext/elide/data/elide2.3.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstext/elide/data/elide2.qml b/tests/auto/declarative/visual/qdeclarativetext/elide/data/elide2.qml
index c592f18..c592f18 100644
--- a/tests/auto/declarative/visual/qmlgraphicstext/elide/data/elide2.qml
+++ b/tests/auto/declarative/visual/qdeclarativetext/elide/data/elide2.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicstext/elide/elide.qml b/tests/auto/declarative/visual/qdeclarativetext/elide/elide.qml
index fa6b5da..fa6b5da 100644
--- a/tests/auto/declarative/visual/qmlgraphicstext/elide/elide.qml
+++ b/tests/auto/declarative/visual/qdeclarativetext/elide/elide.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicstext/elide/elide2.qml b/tests/auto/declarative/visual/qdeclarativetext/elide/elide2.qml
index c163e05..c163e05 100644
--- a/tests/auto/declarative/visual/qmlgraphicstext/elide/elide2.qml
+++ b/tests/auto/declarative/visual/qdeclarativetext/elide/elide2.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicstext/elide/multilength.qml b/tests/auto/declarative/visual/qdeclarativetext/elide/multilength.qml
index ca41eab..ca41eab 100644
--- a/tests/auto/declarative/visual/qmlgraphicstext/elide/multilength.qml
+++ b/tests/auto/declarative/visual/qdeclarativetext/elide/multilength.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicstext/font/data-MAC/plaintext.0.png b/tests/auto/declarative/visual/qdeclarativetext/font/data-MAC/plaintext.0.png
index 67b497f..67b497f 100644
--- a/tests/auto/declarative/visual/qmlgraphicstext/font/data-MAC/plaintext.0.png
+++ b/tests/auto/declarative/visual/qdeclarativetext/font/data-MAC/plaintext.0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstext/font/data-MAC/plaintext.qml b/tests/auto/declarative/visual/qdeclarativetext/font/data-MAC/plaintext.qml
index ab17eb1..ab17eb1 100644
--- a/tests/auto/declarative/visual/qmlgraphicstext/font/data-MAC/plaintext.qml
+++ b/tests/auto/declarative/visual/qdeclarativetext/font/data-MAC/plaintext.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicstext/font/data-MAC/richtext.0.png b/tests/auto/declarative/visual/qdeclarativetext/font/data-MAC/richtext.0.png
index 6379942..6379942 100644
--- a/tests/auto/declarative/visual/qmlgraphicstext/font/data-MAC/richtext.0.png
+++ b/tests/auto/declarative/visual/qdeclarativetext/font/data-MAC/richtext.0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstext/font/data-MAC/richtext.qml b/tests/auto/declarative/visual/qdeclarativetext/font/data-MAC/richtext.qml
index 72499b9..72499b9 100644
--- a/tests/auto/declarative/visual/qmlgraphicstext/font/data-MAC/richtext.qml
+++ b/tests/auto/declarative/visual/qdeclarativetext/font/data-MAC/richtext.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicstext/font/data/plaintext.0.png b/tests/auto/declarative/visual/qdeclarativetext/font/data/plaintext.0.png
index 50d56dc..50d56dc 100644
--- a/tests/auto/declarative/visual/qmlgraphicstext/font/data/plaintext.0.png
+++ b/tests/auto/declarative/visual/qdeclarativetext/font/data/plaintext.0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstext/font/data/plaintext.qml b/tests/auto/declarative/visual/qdeclarativetext/font/data/plaintext.qml
index f4cbcbd..f4cbcbd 100644
--- a/tests/auto/declarative/visual/qmlgraphicstext/font/data/plaintext.qml
+++ b/tests/auto/declarative/visual/qdeclarativetext/font/data/plaintext.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicstext/font/data/richtext.0.png b/tests/auto/declarative/visual/qdeclarativetext/font/data/richtext.0.png
index 2910670..2910670 100644
--- a/tests/auto/declarative/visual/qmlgraphicstext/font/data/richtext.0.png
+++ b/tests/auto/declarative/visual/qdeclarativetext/font/data/richtext.0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstext/font/data/richtext.qml b/tests/auto/declarative/visual/qdeclarativetext/font/data/richtext.qml
index 9f396c2..9f396c2 100644
--- a/tests/auto/declarative/visual/qmlgraphicstext/font/data/richtext.qml
+++ b/tests/auto/declarative/visual/qdeclarativetext/font/data/richtext.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicstext/font/plaintext.qml b/tests/auto/declarative/visual/qdeclarativetext/font/plaintext.qml
index a3aa929..a3aa929 100644
--- a/tests/auto/declarative/visual/qmlgraphicstext/font/plaintext.qml
+++ b/tests/auto/declarative/visual/qdeclarativetext/font/plaintext.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicstext/font/richtext.qml b/tests/auto/declarative/visual/qdeclarativetext/font/richtext.qml
index 35aa232..35aa232 100644
--- a/tests/auto/declarative/visual/qmlgraphicstext/font/richtext.qml
+++ b/tests/auto/declarative/visual/qdeclarativetext/font/richtext.qml
diff --git a/tests/auto/declarative/visual/qdeclarativetextedit/cursorDelegate.qml b/tests/auto/declarative/visual/qdeclarativetextedit/cursorDelegate.qml
new file mode 100644
index 0000000..176a5b8
--- /dev/null
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/cursorDelegate.qml
@@ -0,0 +1,35 @@
+import Qt 4.6
+ Rectangle {
+ resources: [
+ Component { id: cursorA
+ Item { id: cPage;
+ x: Behavior { NumberAnimation { } }
+ y: Behavior { NumberAnimation { } }
+ height: Behavior { NumberAnimation { duration: 200 } }
+ Rectangle { id: cRectangle; color: "black"; y: 1; width: 1; height: parent.height-2;
+ Rectangle { id:top; color: "black"; width: 3; height: 1; x: -1; y:0}
+ Rectangle { id:bottom; color: "black"; width: 3; height: 1; x: -1; anchors.bottom: parent.bottom;}
+ opacity: 1
+ opacity: SequentialAnimation { running: cPage.parent.focus == true; repeat: true;
+ NumberAnimation { properties: "opacity"; to: 1; duration: 500; easing.type: "InQuad"}
+ NumberAnimation { properties: "opacity"; to: 0; duration: 500; easing.type: "OutQuad"}
+ }
+ }
+ width: 1;
+ }
+ }
+ ]
+ width: 400
+ height: 200
+ color: "white"
+ TextEdit { id: mainText
+ text: "Hello World"
+ cursorDelegate: cursorA
+ focus: true
+ font.pixelSize: 28
+ selectionColor: "lightsteelblue"
+ selectedTextColor: "deeppink"
+ color: "forestgreen"
+ anchors.centerIn: parent
+ }
+}
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/cursorDelegate.0.png b/tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/cursorDelegate.0.png
index 464a578..464a578 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/cursorDelegate.0.png
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/cursorDelegate.0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/cursorDelegate.1.png b/tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/cursorDelegate.1.png
index 9beb1ca..9beb1ca 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/cursorDelegate.1.png
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/cursorDelegate.1.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/cursorDelegate.2.png b/tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/cursorDelegate.2.png
index 001be30..001be30 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/cursorDelegate.2.png
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/cursorDelegate.2.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/cursorDelegate.3.png b/tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/cursorDelegate.3.png
index fc3e4b3..fc3e4b3 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/cursorDelegate.3.png
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/cursorDelegate.3.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/cursorDelegate.4.png b/tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/cursorDelegate.4.png
index 24f43e6..24f43e6 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/cursorDelegate.4.png
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/cursorDelegate.4.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/cursorDelegate.5.png b/tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/cursorDelegate.5.png
index 001223b..001223b 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/cursorDelegate.5.png
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/cursorDelegate.5.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/cursorDelegate.6.png b/tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/cursorDelegate.6.png
index 7126e07..7126e07 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/cursorDelegate.6.png
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/cursorDelegate.6.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/cursorDelegate.7.png b/tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/cursorDelegate.7.png
index f0bea88..f0bea88 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/cursorDelegate.7.png
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/cursorDelegate.7.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/cursorDelegate.8.png b/tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/cursorDelegate.8.png
index 4381b8d..4381b8d 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/cursorDelegate.8.png
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/cursorDelegate.8.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/cursorDelegate.qml b/tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/cursorDelegate.qml
index 8ee92d7..8ee92d7 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/cursorDelegate.qml
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/cursorDelegate.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/qt-669.0.png b/tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/qt-669.0.png
index cc1774f..cc1774f 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/qt-669.0.png
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/qt-669.0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/qt-669.1.png b/tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/qt-669.1.png
index 60eba16..60eba16 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/qt-669.1.png
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/qt-669.1.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/qt-669.2.png b/tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/qt-669.2.png
index d4663f7..d4663f7 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/qt-669.2.png
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/qt-669.2.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/qt-669.3.png b/tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/qt-669.3.png
index dc1bb52..dc1bb52 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/qt-669.3.png
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/qt-669.3.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/qt-669.qml b/tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/qt-669.qml
index 84c16e1..84c16e1 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/qt-669.qml
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/qt-669.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data/wrap.0.png b/tests/auto/declarative/visual/qdeclarativetextedit/data-X11/wrap.0.png
index ec65f49..ec65f49 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data/wrap.0.png
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data-X11/wrap.0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data/wrap.1.png b/tests/auto/declarative/visual/qdeclarativetextedit/data-X11/wrap.1.png
index ec65f49..ec65f49 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data/wrap.1.png
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data-X11/wrap.1.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data/wrap.2.png b/tests/auto/declarative/visual/qdeclarativetextedit/data-X11/wrap.2.png
index ec65f49..ec65f49 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data/wrap.2.png
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data-X11/wrap.2.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data/wrap.3.png b/tests/auto/declarative/visual/qdeclarativetextedit/data-X11/wrap.3.png
index ec65f49..ec65f49 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data/wrap.3.png
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data-X11/wrap.3.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data/wrap.4.png b/tests/auto/declarative/visual/qdeclarativetextedit/data-X11/wrap.4.png
index ec65f49..ec65f49 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data/wrap.4.png
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data-X11/wrap.4.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data/wrap.5.png b/tests/auto/declarative/visual/qdeclarativetextedit/data-X11/wrap.5.png
index ec65f49..ec65f49 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data/wrap.5.png
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data-X11/wrap.5.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data/wrap.6.png b/tests/auto/declarative/visual/qdeclarativetextedit/data-X11/wrap.6.png
index ec65f49..ec65f49 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data/wrap.6.png
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data-X11/wrap.6.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data-X11/wrap.qml b/tests/auto/declarative/visual/qdeclarativetextedit/data-X11/wrap.qml
index 4ff00f4..4ff00f4 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data-X11/wrap.qml
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data-X11/wrap.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data/cursorDelegate.0.png b/tests/auto/declarative/visual/qdeclarativetextedit/data/cursorDelegate.0.png
index 555996a..555996a 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data/cursorDelegate.0.png
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data/cursorDelegate.0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data/cursorDelegate.1.png b/tests/auto/declarative/visual/qdeclarativetextedit/data/cursorDelegate.1.png
index b705bad..b705bad 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data/cursorDelegate.1.png
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data/cursorDelegate.1.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data/cursorDelegate.2.png b/tests/auto/declarative/visual/qdeclarativetextedit/data/cursorDelegate.2.png
index 094cd2a..094cd2a 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data/cursorDelegate.2.png
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data/cursorDelegate.2.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data/cursorDelegate.3.png b/tests/auto/declarative/visual/qdeclarativetextedit/data/cursorDelegate.3.png
index 9c519c7..9c519c7 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data/cursorDelegate.3.png
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data/cursorDelegate.3.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data/cursorDelegate.4.png b/tests/auto/declarative/visual/qdeclarativetextedit/data/cursorDelegate.4.png
index 3ec77b5..3ec77b5 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data/cursorDelegate.4.png
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data/cursorDelegate.4.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data/cursorDelegate.5.png b/tests/auto/declarative/visual/qdeclarativetextedit/data/cursorDelegate.5.png
index 579a66e..579a66e 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data/cursorDelegate.5.png
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data/cursorDelegate.5.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data/cursorDelegate.6.png b/tests/auto/declarative/visual/qdeclarativetextedit/data/cursorDelegate.6.png
index 9e5ac90..9e5ac90 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data/cursorDelegate.6.png
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data/cursorDelegate.6.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data/cursorDelegate.7.png b/tests/auto/declarative/visual/qdeclarativetextedit/data/cursorDelegate.7.png
index 9f3acfc..9f3acfc 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data/cursorDelegate.7.png
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data/cursorDelegate.7.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data/cursorDelegate.8.png b/tests/auto/declarative/visual/qdeclarativetextedit/data/cursorDelegate.8.png
index f27518a..f27518a 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data/cursorDelegate.8.png
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data/cursorDelegate.8.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data/cursorDelegate.qml b/tests/auto/declarative/visual/qdeclarativetextedit/data/cursorDelegate.qml
index 8578d48..8578d48 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data/cursorDelegate.qml
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data/cursorDelegate.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data/qt-669.0.png b/tests/auto/declarative/visual/qdeclarativetextedit/data/qt-669.0.png
index 95a835a..95a835a 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data/qt-669.0.png
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data/qt-669.0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data/qt-669.1.png b/tests/auto/declarative/visual/qdeclarativetextedit/data/qt-669.1.png
index 409192c..409192c 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data/qt-669.1.png
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data/qt-669.1.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data/qt-669.2.png b/tests/auto/declarative/visual/qdeclarativetextedit/data/qt-669.2.png
index cd2f112..cd2f112 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data/qt-669.2.png
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data/qt-669.2.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data/qt-669.3.png b/tests/auto/declarative/visual/qdeclarativetextedit/data/qt-669.3.png
index 7191c1e..7191c1e 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data/qt-669.3.png
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data/qt-669.3.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data/qt-669.qml b/tests/auto/declarative/visual/qdeclarativetextedit/data/qt-669.qml
index 352c890..352c890 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data/qt-669.qml
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data/qt-669.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data-X11/wrap.0.png b/tests/auto/declarative/visual/qdeclarativetextedit/data/wrap.0.png
index ec65f49..ec65f49 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data-X11/wrap.0.png
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data/wrap.0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data-X11/wrap.1.png b/tests/auto/declarative/visual/qdeclarativetextedit/data/wrap.1.png
index ec65f49..ec65f49 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data-X11/wrap.1.png
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data/wrap.1.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data-X11/wrap.2.png b/tests/auto/declarative/visual/qdeclarativetextedit/data/wrap.2.png
index ec65f49..ec65f49 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data-X11/wrap.2.png
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data/wrap.2.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data-X11/wrap.3.png b/tests/auto/declarative/visual/qdeclarativetextedit/data/wrap.3.png
index ec65f49..ec65f49 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data-X11/wrap.3.png
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data/wrap.3.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data-X11/wrap.4.png b/tests/auto/declarative/visual/qdeclarativetextedit/data/wrap.4.png
index ec65f49..ec65f49 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data-X11/wrap.4.png
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data/wrap.4.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data-X11/wrap.5.png b/tests/auto/declarative/visual/qdeclarativetextedit/data/wrap.5.png
index ec65f49..ec65f49 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data-X11/wrap.5.png
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data/wrap.5.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data-X11/wrap.6.png b/tests/auto/declarative/visual/qdeclarativetextedit/data/wrap.6.png
index ec65f49..ec65f49 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data-X11/wrap.6.png
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data/wrap.6.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data/wrap.qml b/tests/auto/declarative/visual/qdeclarativetextedit/data/wrap.qml
index f96daa9..f96daa9 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data/wrap.qml
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data/wrap.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/qt-669.qml b/tests/auto/declarative/visual/qdeclarativetextedit/qt-669.qml
index b01ddf8..b01ddf8 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/qt-669.qml
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/qt-669.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/wrap.qml b/tests/auto/declarative/visual/qdeclarativetextedit/wrap.qml
index f9fe025..f9fe025 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/wrap.qml
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/wrap.qml
diff --git a/tests/auto/declarative/visual/qdeclarativetextinput/cursorDelegate.qml b/tests/auto/declarative/visual/qdeclarativetextinput/cursorDelegate.qml
new file mode 100644
index 0000000..6a4e7fa
--- /dev/null
+++ b/tests/auto/declarative/visual/qdeclarativetextinput/cursorDelegate.qml
@@ -0,0 +1,35 @@
+import Qt 4.6
+ Rectangle {
+ resources: [
+ Component { id: cursorA
+ Item { id: cPage;
+ x: Behavior { NumberAnimation { } }
+ y: Behavior { NumberAnimation { } }
+ height: Behavior { NumberAnimation { duration: 200 } }
+ Rectangle { id: cRectangle; color: "black"; y: 1; width: 1; height: parent.height-2;
+ Rectangle { id:top; color: "black"; width: 3; height: 1; x: -1; y:0}
+ Rectangle { id:bottom; color: "black"; width: 3; height: 1; x: -1; anchors.bottom: parent.bottom;}
+ opacity: 1
+ opacity: SequentialAnimation { running: cPage.parent.focus == true; repeat: true;
+ NumberAnimation { properties: "opacity"; to: 1; duration: 500; easing.type: "InQuad"}
+ NumberAnimation { properties: "opacity"; to: 0; duration: 500; easing.type: "OutQuad"}
+ }
+ }
+ width: 1;
+ }
+ }
+ ]
+ width: 400
+ height: 200
+ color: "white"
+ TextInput { id: mainText
+ text: "Hello World"
+ cursorDelegate: cursorA
+ focus: true
+ font.pixelSize: 28
+ selectionColor: "lightsteelblue"
+ selectedTextColor: "deeppink"
+ color: "forestgreen"
+ anchors.centerIn: parent
+ }
+}
diff --git a/tests/auto/declarative/visual/qmlgraphicstextinput/data-MAC/cursorDelegate.0.png b/tests/auto/declarative/visual/qdeclarativetextinput/data-MAC/cursorDelegate.0.png
index 9d0bab2..9d0bab2 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextinput/data-MAC/cursorDelegate.0.png
+++ b/tests/auto/declarative/visual/qdeclarativetextinput/data-MAC/cursorDelegate.0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextinput/data-MAC/cursorDelegate.1.png b/tests/auto/declarative/visual/qdeclarativetextinput/data-MAC/cursorDelegate.1.png
index db66ff7..db66ff7 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextinput/data-MAC/cursorDelegate.1.png
+++ b/tests/auto/declarative/visual/qdeclarativetextinput/data-MAC/cursorDelegate.1.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextinput/data-MAC/cursorDelegate.2.png b/tests/auto/declarative/visual/qdeclarativetextinput/data-MAC/cursorDelegate.2.png
index cbcca68..cbcca68 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextinput/data-MAC/cursorDelegate.2.png
+++ b/tests/auto/declarative/visual/qdeclarativetextinput/data-MAC/cursorDelegate.2.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextinput/data-MAC/cursorDelegate.3.png b/tests/auto/declarative/visual/qdeclarativetextinput/data-MAC/cursorDelegate.3.png
index c22196b..c22196b 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextinput/data-MAC/cursorDelegate.3.png
+++ b/tests/auto/declarative/visual/qdeclarativetextinput/data-MAC/cursorDelegate.3.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextinput/data-MAC/cursorDelegate.4.png b/tests/auto/declarative/visual/qdeclarativetextinput/data-MAC/cursorDelegate.4.png
index a1d051e..a1d051e 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextinput/data-MAC/cursorDelegate.4.png
+++ b/tests/auto/declarative/visual/qdeclarativetextinput/data-MAC/cursorDelegate.4.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextinput/data-MAC/cursorDelegate.5.png b/tests/auto/declarative/visual/qdeclarativetextinput/data-MAC/cursorDelegate.5.png
index 9289dc0..9289dc0 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextinput/data-MAC/cursorDelegate.5.png
+++ b/tests/auto/declarative/visual/qdeclarativetextinput/data-MAC/cursorDelegate.5.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextinput/data-MAC/cursorDelegate.6.png b/tests/auto/declarative/visual/qdeclarativetextinput/data-MAC/cursorDelegate.6.png
index 7331f89..7331f89 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextinput/data-MAC/cursorDelegate.6.png
+++ b/tests/auto/declarative/visual/qdeclarativetextinput/data-MAC/cursorDelegate.6.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextinput/data-MAC/cursorDelegate.7.png b/tests/auto/declarative/visual/qdeclarativetextinput/data-MAC/cursorDelegate.7.png
index 968bdd2..968bdd2 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextinput/data-MAC/cursorDelegate.7.png
+++ b/tests/auto/declarative/visual/qdeclarativetextinput/data-MAC/cursorDelegate.7.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextinput/data-MAC/cursorDelegate.8.png b/tests/auto/declarative/visual/qdeclarativetextinput/data-MAC/cursorDelegate.8.png
index 9a3436a..9a3436a 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextinput/data-MAC/cursorDelegate.8.png
+++ b/tests/auto/declarative/visual/qdeclarativetextinput/data-MAC/cursorDelegate.8.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextinput/data-MAC/cursorDelegate.qml b/tests/auto/declarative/visual/qdeclarativetextinput/data-MAC/cursorDelegate.qml
index 3b664b6..3b664b6 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextinput/data-MAC/cursorDelegate.qml
+++ b/tests/auto/declarative/visual/qdeclarativetextinput/data-MAC/cursorDelegate.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicstextinput/data/echoMode.0.png b/tests/auto/declarative/visual/qdeclarativetextinput/data-X11/echoMode.0.png
index 2b45a06..2b45a06 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextinput/data/echoMode.0.png
+++ b/tests/auto/declarative/visual/qdeclarativetextinput/data-X11/echoMode.0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextinput/data/echoMode.1.png b/tests/auto/declarative/visual/qdeclarativetextinput/data-X11/echoMode.1.png
index 1f5bae0..1f5bae0 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextinput/data/echoMode.1.png
+++ b/tests/auto/declarative/visual/qdeclarativetextinput/data-X11/echoMode.1.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextinput/data/echoMode.2.png b/tests/auto/declarative/visual/qdeclarativetextinput/data-X11/echoMode.2.png
index cb2b5a4..cb2b5a4 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextinput/data/echoMode.2.png
+++ b/tests/auto/declarative/visual/qdeclarativetextinput/data-X11/echoMode.2.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextinput/data/echoMode.3.png b/tests/auto/declarative/visual/qdeclarativetextinput/data-X11/echoMode.3.png
index aa24805..aa24805 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextinput/data/echoMode.3.png
+++ b/tests/auto/declarative/visual/qdeclarativetextinput/data-X11/echoMode.3.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextinput/data/echoMode.4.png b/tests/auto/declarative/visual/qdeclarativetextinput/data-X11/echoMode.4.png
index aa24805..aa24805 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextinput/data/echoMode.4.png
+++ b/tests/auto/declarative/visual/qdeclarativetextinput/data-X11/echoMode.4.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextinput/data-X11/echoMode.qml b/tests/auto/declarative/visual/qdeclarativetextinput/data-X11/echoMode.qml
index dd7b291..dd7b291 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextinput/data-X11/echoMode.qml
+++ b/tests/auto/declarative/visual/qdeclarativetextinput/data-X11/echoMode.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicstextinput/data/hAlign.0.png b/tests/auto/declarative/visual/qdeclarativetextinput/data-X11/hAlign.0.png
index 87c2e07..87c2e07 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextinput/data/hAlign.0.png
+++ b/tests/auto/declarative/visual/qdeclarativetextinput/data-X11/hAlign.0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextinput/data/hAlign.qml b/tests/auto/declarative/visual/qdeclarativetextinput/data-X11/hAlign.qml
index e29ac56..e29ac56 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextinput/data/hAlign.qml
+++ b/tests/auto/declarative/visual/qdeclarativetextinput/data-X11/hAlign.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicstextinput/data/cursorDelegate.0.png b/tests/auto/declarative/visual/qdeclarativetextinput/data/cursorDelegate.0.png
index f04f65e..f04f65e 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextinput/data/cursorDelegate.0.png
+++ b/tests/auto/declarative/visual/qdeclarativetextinput/data/cursorDelegate.0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextinput/data/cursorDelegate.1.png b/tests/auto/declarative/visual/qdeclarativetextinput/data/cursorDelegate.1.png
index 46a703a..46a703a 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextinput/data/cursorDelegate.1.png
+++ b/tests/auto/declarative/visual/qdeclarativetextinput/data/cursorDelegate.1.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextinput/data/cursorDelegate.2.png b/tests/auto/declarative/visual/qdeclarativetextinput/data/cursorDelegate.2.png
index e4a3877..e4a3877 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextinput/data/cursorDelegate.2.png
+++ b/tests/auto/declarative/visual/qdeclarativetextinput/data/cursorDelegate.2.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextinput/data/cursorDelegate.3.png b/tests/auto/declarative/visual/qdeclarativetextinput/data/cursorDelegate.3.png
index 9ef842a..9ef842a 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextinput/data/cursorDelegate.3.png
+++ b/tests/auto/declarative/visual/qdeclarativetextinput/data/cursorDelegate.3.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextinput/data/cursorDelegate.4.png b/tests/auto/declarative/visual/qdeclarativetextinput/data/cursorDelegate.4.png
index 706e2b3..706e2b3 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextinput/data/cursorDelegate.4.png
+++ b/tests/auto/declarative/visual/qdeclarativetextinput/data/cursorDelegate.4.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextinput/data/cursorDelegate.5.png b/tests/auto/declarative/visual/qdeclarativetextinput/data/cursorDelegate.5.png
index bcc86cc..bcc86cc 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextinput/data/cursorDelegate.5.png
+++ b/tests/auto/declarative/visual/qdeclarativetextinput/data/cursorDelegate.5.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextinput/data/cursorDelegate.6.png b/tests/auto/declarative/visual/qdeclarativetextinput/data/cursorDelegate.6.png
index 51ddd44..51ddd44 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextinput/data/cursorDelegate.6.png
+++ b/tests/auto/declarative/visual/qdeclarativetextinput/data/cursorDelegate.6.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextinput/data/cursorDelegate.7.png b/tests/auto/declarative/visual/qdeclarativetextinput/data/cursorDelegate.7.png
index 0a2fdda..0a2fdda 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextinput/data/cursorDelegate.7.png
+++ b/tests/auto/declarative/visual/qdeclarativetextinput/data/cursorDelegate.7.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextinput/data/cursorDelegate.8.png b/tests/auto/declarative/visual/qdeclarativetextinput/data/cursorDelegate.8.png
index 9c88bff..9c88bff 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextinput/data/cursorDelegate.8.png
+++ b/tests/auto/declarative/visual/qdeclarativetextinput/data/cursorDelegate.8.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextinput/data/cursorDelegate.qml b/tests/auto/declarative/visual/qdeclarativetextinput/data/cursorDelegate.qml
index df2dd38..df2dd38 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextinput/data/cursorDelegate.qml
+++ b/tests/auto/declarative/visual/qdeclarativetextinput/data/cursorDelegate.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicstextinput/data-X11/echoMode.0.png b/tests/auto/declarative/visual/qdeclarativetextinput/data/echoMode.0.png
index 2b45a06..2b45a06 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextinput/data-X11/echoMode.0.png
+++ b/tests/auto/declarative/visual/qdeclarativetextinput/data/echoMode.0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextinput/data-X11/echoMode.1.png b/tests/auto/declarative/visual/qdeclarativetextinput/data/echoMode.1.png
index 1f5bae0..1f5bae0 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextinput/data-X11/echoMode.1.png
+++ b/tests/auto/declarative/visual/qdeclarativetextinput/data/echoMode.1.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextinput/data-X11/echoMode.2.png b/tests/auto/declarative/visual/qdeclarativetextinput/data/echoMode.2.png
index cb2b5a4..cb2b5a4 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextinput/data-X11/echoMode.2.png
+++ b/tests/auto/declarative/visual/qdeclarativetextinput/data/echoMode.2.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextinput/data-X11/echoMode.3.png b/tests/auto/declarative/visual/qdeclarativetextinput/data/echoMode.3.png
index aa24805..aa24805 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextinput/data-X11/echoMode.3.png
+++ b/tests/auto/declarative/visual/qdeclarativetextinput/data/echoMode.3.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextinput/data-X11/echoMode.4.png b/tests/auto/declarative/visual/qdeclarativetextinput/data/echoMode.4.png
index aa24805..aa24805 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextinput/data-X11/echoMode.4.png
+++ b/tests/auto/declarative/visual/qdeclarativetextinput/data/echoMode.4.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextinput/data/echoMode.qml b/tests/auto/declarative/visual/qdeclarativetextinput/data/echoMode.qml
index 873a86d..873a86d 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextinput/data/echoMode.qml
+++ b/tests/auto/declarative/visual/qdeclarativetextinput/data/echoMode.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicstextinput/data-X11/hAlign.0.png b/tests/auto/declarative/visual/qdeclarativetextinput/data/hAlign.0.png
index 87c2e07..87c2e07 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextinput/data-X11/hAlign.0.png
+++ b/tests/auto/declarative/visual/qdeclarativetextinput/data/hAlign.0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextinput/data-X11/hAlign.qml b/tests/auto/declarative/visual/qdeclarativetextinput/data/hAlign.qml
index e29ac56..e29ac56 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextinput/data-X11/hAlign.qml
+++ b/tests/auto/declarative/visual/qdeclarativetextinput/data/hAlign.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicstextinput/echoMode.qml b/tests/auto/declarative/visual/qdeclarativetextinput/echoMode.qml
index b0b50e4..b0b50e4 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextinput/echoMode.qml
+++ b/tests/auto/declarative/visual/qdeclarativetextinput/echoMode.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicstextinput/hAlign.qml b/tests/auto/declarative/visual/qdeclarativetextinput/hAlign.qml
index 2d65adf..2d65adf 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextinput/hAlign.qml
+++ b/tests/auto/declarative/visual/qdeclarativetextinput/hAlign.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicsborderimage/content/MyBorderImage.qml b/tests/auto/declarative/visual/qmlgraphicsborderimage/content/MyBorderImage.qml
deleted file mode 100644
index eb1ec00..0000000
--- a/tests/auto/declarative/visual/qmlgraphicsborderimage/content/MyBorderImage.qml
+++ /dev/null
@@ -1,38 +0,0 @@
-import Qt 4.6
-
-Item {
- property alias horizontalMode: image.horizontalTileMode
- property alias verticalMode: image.verticalTileMode
- property alias source: image.source
- property alias antialiased: image.smooth
-
- property int minWidth
- property int minHeight
- property int maxWidth
- property int maxHeight
- property int margin
-
- id: container
- width: 240; height: 240
-
- BorderImage {
- id: image; x: container.width / 2 - width / 2; y: container.height / 2 - height / 2
-
- width: SequentialAnimation {
- repeat: true
- NumberAnimation { from: container.minWidth; to: container.maxWidth; duration: 2000; easing: "easeInOutQuad"}
- NumberAnimation { from: container.maxWidth; to: container.minWidth; duration: 2000; easing: "easeInOutQuad" }
- }
-
- height: SequentialAnimation {
- repeat: true
- NumberAnimation { from: container.minHeight; to: container.maxHeight; duration: 2000; easing: "easeInOutQuad"}
- NumberAnimation { from: container.maxHeight; to: container.minHeight; duration: 2000; easing: "easeInOutQuad" }
- }
-
- border.top: container.margin
- border.left: container.margin
- border.bottom: container.margin
- border.right: container.margin
- }
-}
diff --git a/tests/auto/declarative/visual/qmlgraphicsflickable/flickable-horizontal.qml b/tests/auto/declarative/visual/qmlgraphicsflickable/flickable-horizontal.qml
deleted file mode 100644
index 1a7366d..0000000
--- a/tests/auto/declarative/visual/qmlgraphicsflickable/flickable-horizontal.qml
+++ /dev/null
@@ -1,37 +0,0 @@
-import Qt 4.6
-
-Rectangle {
- color: "lightSteelBlue"
- width: 600; height: 300
-
- ListModel {
- id: list
- ListElement { dayColor: "steelblue" }
- ListElement { dayColor: "blue" }
- ListElement { dayColor: "yellow" }
- ListElement { dayColor: "purple" }
- ListElement { dayColor: "red" }
- ListElement { dayColor: "green" }
- ListElement { dayColor: "orange" }
- }
-
- Flickable {
- id: flickable
- anchors.fill: parent; viewportWidth: row.width
-
- Row {
- id: row
- Repeater {
- model: list
- Rectangle { width: 200; height: 300; color: dayColor }
- }
- }
- }
- Rectangle {
- radius: 3
- y: flickable.height-8
- height: 8
- x: flickable.visibleArea.xPosition * flickable.width
- width: flickable.visibleArea.widthRatio * flickable.width
- }
-}
diff --git a/tests/auto/declarative/visual/qmlgraphicsflickable/flickable-vertical.qml b/tests/auto/declarative/visual/qmlgraphicsflickable/flickable-vertical.qml
deleted file mode 100644
index 6204aa9..0000000
--- a/tests/auto/declarative/visual/qmlgraphicsflickable/flickable-vertical.qml
+++ /dev/null
@@ -1,91 +0,0 @@
-import Qt 4.6
-
-Rectangle {
- color: "lightSteelBlue"
- width: 300; height: 600
-
- ListModel {
- id: list
- ListElement { dayColor: "steelblue" }
- ListElement { dayColor: "blue" }
- ListElement { dayColor: "yellow" }
- ListElement { dayColor: "purple" }
- ListElement { dayColor: "red" }
- ListElement { dayColor: "green" }
- ListElement { dayColor: "orange" }
- }
-
- flickable {
- id: flick
- height: parent.height-50
- width: parent.width; viewportHeight: column.height
-
- Column {
- id: column
- Repeater {
- model: list
- Rectangle { width: 300; height: 200; color: mr.pressed ? "black" : dayColor
- MouseArea {
- id: mr
- anchors.fill: parent
- }
- }
- }
- }
- clip: true
- reportedVelocitySmoothing: 1000
- }
- Rectangle {
- radius: 3
- x: flick.width-8
- width: 8
- y: flick.visibleArea.yPosition * flick.height
- height: flick.visibleArea.heightRatio * flick.height
- }
-
- // click to toggle interactive flag
- Rectangle {
- width: 64
- height: 48
- y: parent.height - 50
- color: "red"
- MouseArea {
- anchors.fill: parent
- onClicked: flick.interactive = flick.interactive ? false : true
- }
- }
-
- // click to toggle click delay
- Rectangle {
- width: 64
- height: 48
- x: 66
- y: parent.height - 50
- color: "green"
- MouseArea {
- anchors.fill: parent
- onClicked: flick.pressDelay = flick.pressDelay > 0 ? 0 : 500
- }
- }
-
- // click to toggle overshoot
- Rectangle {
- width: 64
- height: 48
- x: 130
- y: parent.height - 50
- color: "yellow"
- MouseArea {
- anchors.fill: parent
- onClicked: flick.overShoot = flick.overShoot > 0 ? 0 : 30
- }
- }
-
- Rectangle {
- width: Math.abs(flick.verticalVelocity)/100
- height: 50
- x: 200
- y: parent.height - 50
- color: blue
- }
-}
diff --git a/tests/auto/declarative/visual/qmlgraphicsflipable/test-flipable.qml b/tests/auto/declarative/visual/qmlgraphicsflipable/test-flipable.qml
deleted file mode 100644
index c33a319..0000000
--- a/tests/auto/declarative/visual/qmlgraphicsflipable/test-flipable.qml
+++ /dev/null
@@ -1,79 +0,0 @@
-import Qt 4.6
-
-Rectangle {
- width: 400; height: 240
- color: "white"
-
- Timer {
- interval: 3000; running: true; repeat: true; triggeredOnStart: true
- onTriggered: {
- if (flipable.state == '') flipable.state = 'back'; else flipable.state = ''
- if (flipable2.state == '') flipable2.state = 'back'; else flipable2.state = ''
- }
- }
-
- Flipable {
- id: flipable
- width: 200; height: 200
-
- transform: Rotation {
- id: rotation; angle: 0
- origin.x: 100; origin.y: 100
- axis.x: 0; axis.y: 1; axis.z: 0
- }
-
- front: Rectangle {
- color: "steelblue"; width: 200; height: 200
- }
-
- back: Rectangle {
- color: "deeppink"; width: 200; height: 200
- }
-
- states: State {
- name: "back"
- PropertyChanges { target: rotation; angle: 180 }
- }
-
- transitions: Transition {
- NumberAnimation { easing: "easeInOutQuad"; properties: "angle"; duration: 3000 }
- }
- }
-
- Flipable {
- id: flipable2
- x: 200; width: 200; height: 200
-
- transform: Rotation {
- id: rotation2; angle: 0
- origin.x: 100; origin.y: 100
- axis.x: 1; axis.z: 0
- }
-
- front: Rectangle {
- color: "deeppink"; width: 200; height: 200
- }
-
- back: Rectangle {
- color: "steelblue"; width: 200; height: 200
- }
-
- states: State {
- name: "back"
- PropertyChanges { target: rotation2; angle: 180 }
- }
-
- transitions: Transition {
- NumberAnimation { easing: "easeInOutQuad"; properties: "angle"; duration: 3000 }
- }
- }
-
- Rectangle {
- x: 25; width: 150; y: 210; height: 20; color: "black"
- visible: flipable.side == Flipable.Front
- }
- Rectangle {
- x: 225; width: 150; y: 210; height: 20; color: "black"
- visible: flipable2.side == Flipable.Back
- }
-}
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/cursorDelegate.qml b/tests/auto/declarative/visual/qmlgraphicstextedit/cursorDelegate.qml
deleted file mode 100644
index e0c5db4..0000000
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/cursorDelegate.qml
+++ /dev/null
@@ -1,35 +0,0 @@
-import Qt 4.6
- Rectangle {
- resources: [
- Component { id: cursorA
- Item { id: cPage;
- x: Behavior { NumberAnimation { } }
- y: Behavior { NumberAnimation { } }
- height: Behavior { NumberAnimation { duration: 200 } }
- Rectangle { id: cRectangle; color: "black"; y: 1; width: 1; height: parent.height-2;
- Rectangle { id:top; color: "black"; width: 3; height: 1; x: -1; y:0}
- Rectangle { id:bottom; color: "black"; width: 3; height: 1; x: -1; anchors.bottom: parent.bottom;}
- opacity: 1
- opacity: SequentialAnimation { running: cPage.parent.focus == true; repeat: true;
- NumberAnimation { properties: "opacity"; to: 1; duration: 500; easing: "easeInQuad"}
- NumberAnimation { properties: "opacity"; to: 0; duration: 500; easing: "easeOutQuad"}
- }
- }
- width: 1;
- }
- }
- ]
- width: 400
- height: 200
- color: "white"
- TextEdit { id: mainText
- text: "Hello World"
- cursorDelegate: cursorA
- focus: true
- font.pixelSize: 28
- selectionColor: "lightsteelblue"
- selectedTextColor: "deeppink"
- color: "forestgreen"
- anchors.centerIn: parent
- }
-}
diff --git a/tests/auto/declarative/visual/qmlgraphicstextinput/cursorDelegate.qml b/tests/auto/declarative/visual/qmlgraphicstextinput/cursorDelegate.qml
deleted file mode 100644
index 0038664..0000000
--- a/tests/auto/declarative/visual/qmlgraphicstextinput/cursorDelegate.qml
+++ /dev/null
@@ -1,35 +0,0 @@
-import Qt 4.6
- Rectangle {
- resources: [
- Component { id: cursorA
- Item { id: cPage;
- x: Behavior { NumberAnimation { } }
- y: Behavior { NumberAnimation { } }
- height: Behavior { NumberAnimation { duration: 200 } }
- Rectangle { id: cRectangle; color: "black"; y: 1; width: 1; height: parent.height-2;
- Rectangle { id:top; color: "black"; width: 3; height: 1; x: -1; y:0}
- Rectangle { id:bottom; color: "black"; width: 3; height: 1; x: -1; anchors.bottom: parent.bottom;}
- opacity: 1
- opacity: SequentialAnimation { running: cPage.parent.focus == true; repeat: true;
- NumberAnimation { properties: "opacity"; to: 1; duration: 500; easing: "easeInQuad"}
- NumberAnimation { properties: "opacity"; to: 0; duration: 500; easing: "easeOutQuad"}
- }
- }
- width: 1;
- }
- }
- ]
- width: 400
- height: 200
- color: "white"
- TextInput { id: mainText
- text: "Hello World"
- cursorDelegate: cursorA
- focus: true
- font.pixelSize: 28
- selectionColor: "lightsteelblue"
- selectedTextColor: "deeppink"
- color: "forestgreen"
- anchors.centerIn: parent
- }
-}
diff --git a/tests/auto/declarative/visual/qmlspringfollow/follow.qml b/tests/auto/declarative/visual/qmlspringfollow/follow.qml
deleted file mode 100644
index a85a778..0000000
--- a/tests/auto/declarative/visual/qmlspringfollow/follow.qml
+++ /dev/null
@@ -1,71 +0,0 @@
-import Qt 4.6
-
-Rectangle {
- color: "#ffffff"
- width: 320; height: 240
- Rectangle {
- id: rect
- color: "#00ff00"
- y: 200; width: 60; height: 20
- y: SequentialAnimation {
- repeat: true
- NumberAnimation {
- to: 20; duration: 500
- easing: "easeInOutQuad"
- }
- NumberAnimation {
- to: 200; duration: 2000
- easing: "easeOutBounce"
- }
- PauseAnimation { duration: 1000 }
- }
- }
-
- // Velocity
- Rectangle {
- color: "#ff0000"
- x: rect.width; width: rect.width; height: 20
- y: 200
- y: SpringFollow { source: rect.y; velocity: 200 }
- }
-
- // Spring
- Rectangle {
- color: "#ff0000"
- x: rect.width * 2; width: rect.width/2; height: 20
- y: 200
- y: SpringFollow { source: rect.y; spring: 1.0; damping: 0.2 }
- }
- Rectangle {
- color: "#880000"
- x: rect.width * 2.5; width: rect.width/2; height: 20
- y: 200
- y: SpringFollow { source: rect.y; spring: 1.0; damping: 0.2; mass: 3.0 } // "heavier" object
- }
-
- // Follow mouse
- MouseArea {
- id: mouseRegion
- anchors.fill: parent
- Rectangle {
- id: ball
- width: 20; height: 20
- radius: 10
- color: "#0000ff"
- x: SpringFollow { id: f1; source: mouseRegion.mouseX-10; spring: 1.0; damping: 0.05; epsilon: 0.25 }
- y: SpringFollow { id: f2; source: mouseRegion.mouseY-10; spring: 1.0; damping: 0.05; epsilon: 0.25 }
- states: [
- State {
- name: "following"
- when: !f1.inSync || !f2.inSync
- PropertyChanges { target: ball; color: "#ff0000" }
- }
- ]
- transitions: [
- Transition {
- ColorAnimation { duration: 200 }
- }
- ]
- }
- }
-}
diff --git a/tests/auto/declarative/visual/tst_visual.cpp b/tests/auto/declarative/visual/tst_visual.cpp
index 8f41bef..cd88e87 100644
--- a/tests/auto/declarative/visual/tst_visual.cpp
+++ b/tests/auto/declarative/visual/tst_visual.cpp
@@ -39,7 +39,7 @@
**
****************************************************************************/
#include <qtest.h>
-#include <QmlView>
+#include <QDeclarativeView>
#include <QApplication>
#include <QLibraryInfo>
#include <QDir>
@@ -65,30 +65,30 @@ private slots:
void visual();
private:
- QString qmlviewer;
+ QString qmlruntime;
};
tst_visual::tst_visual()
{
- qmlviewer = viewer();
+ qmlruntime = viewer();
}
QString tst_visual::viewer()
{
QString binaries = QLibraryInfo::location(QLibraryInfo::BinariesPath);
- QString qmlviewer;
+ QString qmlruntime;
#if defined(Q_WS_MAC)
- qmlviewer = QDir(binaries).absoluteFilePath("qmlviewer.app/Contents/MacOS/qmlviewer");
+ qmlruntime = QDir(binaries).absoluteFilePath("qml.app/Contents/MacOS/qml");
#elif defined(Q_WS_WIN)
- qmlviewer = QDir(binaries).absoluteFilePath("qmlviewer.exe");
+ qmlruntime = QDir(binaries).absoluteFilePath("qml.exe");
#else
- qmlviewer = QDir(binaries).absoluteFilePath("qmlviewer");
+ qmlruntime = QDir(binaries).absoluteFilePath("qml");
#endif
- return qmlviewer;
+ return qmlruntime;
}
void tst_visual::visual_data()
@@ -118,7 +118,7 @@ void tst_visual::visual()
<< "-scriptopts" << "play,testimages,testerror,exitoncomplete,exitonfailure"
<< file;
QProcess p;
- p.start(qmlviewer, arguments);
+ p.start(qmlruntime, arguments);
QVERIFY(p.waitForFinished());
if (p.exitCode() != 0)
qDebug() << p.readAllStandardError();
@@ -211,7 +211,7 @@ void action(Mode mode, const QString &file)
QStringList arguments;
switch (mode) {
case Test:
- // Don't run qmlviewer
+ // Don't run qml
break;
case Record:
arguments << "-script" << testdata
diff --git a/tests/auto/qdatastream/tst_qdatastream.cpp b/tests/auto/qdatastream/tst_qdatastream.cpp
index c94ea7b..31e12fe 100644
--- a/tests/auto/qdatastream/tst_qdatastream.cpp
+++ b/tests/auto/qdatastream/tst_qdatastream.cpp
@@ -162,6 +162,9 @@ private slots:
void stream_QIcon_data();
void stream_QIcon();
+ void stream_QEasingCurve_data();
+ void stream_QEasingCurve();
+
void stream_atEnd_data();
void stream_atEnd();
@@ -243,6 +246,7 @@ private:
void writeqint64(QDataStream *s);
void writeQWMatrix(QDataStream *s);
void writeQIcon(QDataStream *s);
+ void writeQEasingCurve(QDataStream *s);
void readbool(QDataStream *s);
void readQBool(QDataStream *s);
@@ -272,6 +276,7 @@ private:
void readqint64(QDataStream *s);
void readQWMatrix(QDataStream *s);
void readQIcon(QDataStream *s);
+ void readQEasingCurve(QDataStream *s);
private:
QString svgFile;
@@ -687,6 +692,70 @@ void tst_QDataStream::readHash(QDataStream *s)
// ************************************
+static QEasingCurve QEasingCurveData(int index)
+{
+ QEasingCurve easing;
+
+ switch (index) {
+ case 0:
+ default:
+ break;
+ case 1:
+ easing.setType(QEasingCurve::Linear);
+ break;
+ case 2:
+ easing.setType(QEasingCurve::OutCubic);
+ break;
+ case 3:
+ easing.setType(QEasingCurve::InOutSine);
+ break;
+ case 4:
+ easing.setType(QEasingCurve::InOutElastic);
+ easing.setPeriod(1.5);
+ easing.setAmplitude(2.0);
+ break;
+ case 5:
+ easing.setType(QEasingCurve::OutInBack);
+ break;
+ case 6:
+ easing.setType(QEasingCurve::OutCurve);
+ break;
+ case 7:
+ easing.setType(QEasingCurve::InOutBack);
+ easing.setOvershoot(0.5);
+ break;
+ }
+ return easing;
+}
+#define MAX_EASING_DATA 8
+
+void tst_QDataStream::stream_QEasingCurve_data()
+{
+ stream_data(MAX_EASING_DATA);
+}
+
+void tst_QDataStream::stream_QEasingCurve()
+{
+ STREAM_IMPL(QEasingCurve);
+}
+
+void tst_QDataStream::writeQEasingCurve(QDataStream* s)
+{
+ QEasingCurve test(QEasingCurveData(dataIndex(QTest::currentDataTag())));
+ *s << test;
+}
+
+void tst_QDataStream::readQEasingCurve(QDataStream *s)
+{
+ QEasingCurve S;
+ QEasingCurve expected(QEasingCurveData(dataIndex(QTest::currentDataTag())));
+
+ *s >> S;
+ QCOMPARE(S, expected);
+}
+
+// ************************************
+
// contains some quint64 testing as well
#define MAX_qint64_DATA 4
diff --git a/tests/auto/qdeclarativeaudio/qdeclarativeaudio.pro b/tests/auto/qdeclarativeaudio/qdeclarativeaudio.pro
new file mode 100644
index 0000000..13bf606
--- /dev/null
+++ b/tests/auto/qdeclarativeaudio/qdeclarativeaudio.pro
@@ -0,0 +1,4 @@
+load(qttest_p4)
+SOURCES += tst_qdeclarativeaudio.cpp
+
+QT += multimedia declarative
diff --git a/tests/auto/qdeclarativeaudio/tst_qdeclarativeaudio.cpp b/tests/auto/qdeclarativeaudio/tst_qdeclarativeaudio.cpp
new file mode 100644
index 0000000..11439ce
--- /dev/null
+++ b/tests/auto/qdeclarativeaudio/tst_qdeclarativeaudio.cpp
@@ -0,0 +1,1200 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+
+#include <QtMultimedia/private/qdeclarativeaudio_p.h>
+
+#include <QtGui/qapplication.h>
+#include <QtMultimedia/qmediaplayercontrol.h>
+#include <QtMultimedia/qmediaservice.h>
+#include <QtMultimedia/qmetadatacontrol.h>
+
+
+class tst_QmlAudio : public QObject
+{
+ Q_OBJECT
+public slots:
+ void initTestCase();
+
+private slots:
+ void nullPlayerControl();
+ void nullMetaDataControl();
+ void nullService();
+
+ void source();
+ void playing();
+ void paused();
+ void duration();
+ void position();
+ void volume();
+ void muted();
+ void bufferProgress();
+ void seekable();
+ void playbackRate();
+ void status();
+ void metaData_data();
+ void metaData();
+ void error();
+};
+
+Q_DECLARE_METATYPE(QtMultimedia::MetaData);
+Q_DECLARE_METATYPE(QDeclarativeAudio::Error);
+
+class QtTestMediaPlayerControl : public QMediaPlayerControl
+{
+ Q_OBJECT
+public:
+ QtTestMediaPlayerControl(QObject *parent = 0)
+ : QMediaPlayerControl(parent)
+ , m_state(QMediaPlayer::StoppedState)
+ , m_mediaStatus(QMediaPlayer::NoMedia)
+ , m_duration(0)
+ , m_position(0)
+ , m_playbackRate(1.0)
+ , m_volume(50)
+ , m_bufferStatus(0)
+ , m_muted(false)
+ , m_audioAvailable(false)
+ , m_videoAvailable(false)
+ , m_seekable(false)
+ {
+ }
+
+ QMediaPlayer::State state() const { return m_state; }
+ void updateState(QMediaPlayer::State state) { emit stateChanged(m_state = state); }
+
+ QMediaPlayer::MediaStatus mediaStatus() const { return m_mediaStatus; }
+ void updateMediaStatus(QMediaPlayer::MediaStatus status) {
+ emit mediaStatusChanged(m_mediaStatus = status); }
+ void updateMediaStatus(QMediaPlayer::MediaStatus status, QMediaPlayer::State state)
+ {
+ m_mediaStatus = status;
+ m_state = state;
+
+ emit mediaStatusChanged(m_mediaStatus);
+ emit stateChanged(m_state);
+ }
+
+ qint64 duration() const { return m_duration; }
+ void setDuration(qint64 duration) { emit durationChanged(m_duration = duration); }
+
+ qint64 position() const { return m_position; }
+ void setPosition(qint64 position) { emit positionChanged(m_position = position); }
+
+ int volume() const { return m_volume; }
+ void setVolume(int volume) { emit volumeChanged(m_volume = volume); }
+
+ bool isMuted() const { return m_muted; }
+ void setMuted(bool muted) { emit mutedChanged(m_muted = muted); }
+
+ int bufferStatus() const { return m_bufferStatus; }
+ void setBufferStatus(int status) { emit bufferStatusChanged(m_bufferStatus = status); }
+
+ bool isAudioAvailable() const { return m_audioAvailable; }
+ void setAudioAvailable(bool available) {
+ emit audioAvailableChanged(m_audioAvailable = available); }
+ bool isVideoAvailable() const { return m_videoAvailable; }
+ void setVideoAvailable(bool available) {
+ emit videoAvailableChanged(m_videoAvailable = available); }
+
+ bool isSeekable() const { return m_seekable; }
+ void setSeekable(bool seekable) { emit seekableChanged(m_seekable = seekable); }
+
+ QMediaTimeRange availablePlaybackRanges() const { return QMediaTimeRange(); }
+
+ qreal playbackRate() const { return m_playbackRate; }
+ void setPlaybackRate(qreal rate) { emit playbackRateChanged(m_playbackRate = rate); }
+
+ QMediaContent media() const { return m_media; }
+ const QIODevice *mediaStream() const { return 0; }
+ void setMedia(const QMediaContent &media, QIODevice *)
+ {
+ m_media = media;
+
+ m_mediaStatus = m_media.isNull()
+ ? QMediaPlayer::NoMedia
+ : QMediaPlayer::LoadingMedia;
+
+ emit mediaChanged(m_media);
+ emit mediaStatusChanged(m_mediaStatus);
+ }
+
+ void play() { emit stateChanged(m_state = QMediaPlayer::PlayingState); }
+ void pause() { emit stateChanged(m_state = QMediaPlayer::PausedState); }
+ void stop() { emit stateChanged(m_state = QMediaPlayer::StoppedState); }
+
+ void emitError(QMediaPlayer::Error err, const QString &errorString) {
+ emit error(err, errorString); }
+
+private:
+ QMediaPlayer::State m_state;
+ QMediaPlayer::MediaStatus m_mediaStatus;
+ qint64 m_duration;
+ qint64 m_position;
+ qreal m_playbackRate;
+ int m_volume;
+ int m_bufferStatus;
+ bool m_muted;
+ bool m_audioAvailable;
+ bool m_videoAvailable;
+ bool m_seekable;
+ QMediaContent m_media;
+};
+
+class QtTestMetaDataControl : public QMetaDataControl
+{
+ Q_OBJECT
+public:
+ QtTestMetaDataControl(QObject *parent = 0)
+ : QMetaDataControl(parent)
+ {
+ }
+
+ bool isWritable() const { return true; }
+ bool isMetaDataAvailable() const { return true; }
+
+ QVariant metaData(QtMultimedia::MetaData key) const { return m_metaData.value(key); }
+ void setMetaData(QtMultimedia::MetaData key, const QVariant &value) {
+ m_metaData.insert(key, value); emit metaDataChanged(); }
+ void setMetaData(const QMap<QtMultimedia::MetaData, QVariant> &metaData) {
+ m_metaData = metaData; emit metaDataChanged(); }
+
+ QList<QtMultimedia::MetaData> availableMetaData() const { return m_metaData.keys(); }
+
+ QVariant extendedMetaData(const QString &) const { return QVariant(); }
+ void setExtendedMetaData(const QString &, const QVariant &) {}
+ QStringList availableExtendedMetaData() const { return QStringList(); }
+
+private:
+ QMap<QtMultimedia::MetaData, QVariant> m_metaData;
+};
+
+class QtTestMediaService : public QMediaService
+{
+ Q_OBJECT
+public:
+ QtTestMediaService(
+ QtTestMediaPlayerControl *playerControl,
+ QtTestMetaDataControl *metaDataControl,
+ QObject *parent)
+ : QMediaService(parent)
+ , playerControl(playerControl)
+ , metaDataControl(metaDataControl)
+ {
+ }
+
+ QMediaControl *control(const char *name) const
+ {
+ if (qstrcmp(name, QMediaPlayerControl_iid) == 0)
+ return playerControl;
+ else if (qstrcmp(name, QMetaDataControl_iid) == 0)
+ return metaDataControl;
+ else
+ return 0;
+ }
+
+ QtTestMediaPlayerControl *playerControl;
+ QtTestMetaDataControl *metaDataControl;
+};
+
+class QtTestMediaServiceProvider : public QMediaServiceProvider
+{
+ Q_OBJECT
+public:
+ QtTestMediaServiceProvider()
+ : service(new QtTestMediaService(
+ new QtTestMediaPlayerControl(this), new QtTestMetaDataControl(this), this))
+ {
+ setDefaultServiceProvider(this);
+ }
+
+ QtTestMediaServiceProvider(QtTestMediaService *service)
+ : service(service)
+ {
+ setDefaultServiceProvider(this);
+ }
+
+ QtTestMediaServiceProvider(
+ QtTestMediaPlayerControl *playerControl, QtTestMetaDataControl *metaDataControl)
+ : service(new QtTestMediaService(playerControl, metaDataControl, this))
+ {
+ setDefaultServiceProvider(this);
+ }
+
+ ~QtTestMediaServiceProvider()
+ {
+ setDefaultServiceProvider(0);
+ }
+
+ QMediaService *requestService(
+ const QByteArray &type,
+ const QMediaServiceProviderHint & = QMediaServiceProviderHint())
+ {
+ requestedService = type;
+
+ return service;
+ }
+
+ void releaseService(QMediaService *) {}
+
+ inline QtTestMediaPlayerControl *playerControl() { return service->playerControl; }
+ inline QtTestMetaDataControl *metaDataControl() { return service->metaDataControl; }
+
+ QtTestMediaService *service;
+ QByteArray requestedService;
+};
+
+
+void tst_QmlAudio::initTestCase()
+{
+ qRegisterMetaType<QDeclarativeAudio::Error>();
+}
+
+void tst_QmlAudio::nullPlayerControl()
+{
+ QtTestMetaDataControl metaDataControl;
+ QtTestMediaServiceProvider provider(0, &metaDataControl);
+
+ QDeclarativeAudio audio;
+
+ QCOMPARE(audio.source(), QUrl());
+ audio.setSource(QUrl("http://example.com"));
+ QCOMPARE(audio.source(), QUrl());
+
+ QCOMPARE(audio.isPlaying(), false);
+ audio.setPlaying(true);
+ QCOMPARE(audio.isPlaying(), false);
+ audio.play();
+ QCOMPARE(audio.isPlaying(), false);
+
+ QCOMPARE(audio.isPaused(), false);
+ audio.pause();
+ QCOMPARE(audio.isPaused(), false);
+ audio.setPaused(true);
+ QCOMPARE(audio.isPaused(), true);
+
+ QCOMPARE(audio.duration(), 0);
+
+ QCOMPARE(audio.position(), 0);
+ audio.setPosition(10000);
+ QCOMPARE(audio.position(), 0);
+
+ QCOMPARE(audio.volume(), qreal(0));
+ audio.setVolume(50);
+ QCOMPARE(audio.volume(), qreal(0));
+
+ QCOMPARE(audio.isMuted(), false);
+ audio.setMuted(true);
+ QCOMPARE(audio.isMuted(), false);
+
+ QCOMPARE(audio.bufferProgress(), qreal(0));
+
+ QCOMPARE(audio.isSeekable(), false);
+
+ QCOMPARE(audio.playbackRate(), qreal(1.0));
+
+ QCOMPARE(audio.status(), QDeclarativeAudio::NoMedia);
+
+ QCOMPARE(audio.error(), QDeclarativeAudio::ServiceMissing);
+}
+
+void tst_QmlAudio::nullMetaDataControl()
+{
+ QtTestMediaPlayerControl playerControl;
+ QtTestMediaServiceProvider provider(&playerControl, 0);
+
+ QDeclarativeAudio audio;
+
+ QCOMPARE(audio.metaObject()->indexOfProperty("title"), -1);
+ QCOMPARE(audio.metaObject()->indexOfProperty("genre"), -1);
+ QCOMPARE(audio.metaObject()->indexOfProperty("description"), -1);
+}
+
+void tst_QmlAudio::nullService()
+{
+ QtTestMediaServiceProvider provider(0);
+
+ QDeclarativeAudio audio;
+
+ QCOMPARE(audio.source(), QUrl());
+ audio.setSource(QUrl("http://example.com"));
+ QCOMPARE(audio.source(), QUrl());
+
+ QCOMPARE(audio.isPlaying(), false);
+ audio.setPlaying(true);
+ QCOMPARE(audio.isPlaying(), false);
+ audio.play();
+ QCOMPARE(audio.isPlaying(), false);
+
+ QCOMPARE(audio.isPaused(), false);
+ audio.pause();
+ QCOMPARE(audio.isPaused(), false);
+ audio.setPaused(true);
+ QCOMPARE(audio.isPaused(), true);
+
+ QCOMPARE(audio.duration(), 0);
+
+ QCOMPARE(audio.position(), 0);
+ audio.setPosition(10000);
+ QCOMPARE(audio.position(), 0);
+
+ QCOMPARE(audio.volume(), qreal(0));
+ audio.setVolume(50);
+ QCOMPARE(audio.volume(), qreal(0));
+
+ QCOMPARE(audio.isMuted(), false);
+ audio.setMuted(true);
+ QCOMPARE(audio.isMuted(), false);
+
+ QCOMPARE(audio.bufferProgress(), qreal(0));
+
+ QCOMPARE(audio.isSeekable(), false);
+
+ QCOMPARE(audio.playbackRate(), qreal(1.0));
+
+ QCOMPARE(audio.status(), QDeclarativeAudio::NoMedia);
+
+ QCOMPARE(audio.error(), QDeclarativeAudio::ServiceMissing);
+
+ QCOMPARE(audio.metaObject()->indexOfProperty("title"), -1);
+ QCOMPARE(audio.metaObject()->indexOfProperty("genre"), -1);
+ QCOMPARE(audio.metaObject()->indexOfProperty("description"), -1);
+}
+
+void tst_QmlAudio::source()
+{
+ const QUrl url1("http://example.com");
+ const QUrl url2("file:///local/path");
+ const QUrl url3;
+
+ QtTestMediaServiceProvider provider;
+ QDeclarativeAudio audio;
+
+ QSignalSpy spy(&audio, SIGNAL(sourceChanged()));
+
+ audio.setSource(url1);
+ QCOMPARE(audio.source(), url1);
+ QCOMPARE(provider.playerControl()->media().canonicalUrl(), url1);
+ QCOMPARE(spy.count(), 1);
+
+ audio.setSource(url2);
+ QCOMPARE(audio.source(), url2);
+ QCOMPARE(provider.playerControl()->media().canonicalUrl(), url2);
+ QCOMPARE(spy.count(), 2);
+
+ audio.setSource(url3);
+ QCOMPARE(audio.source(), url3);
+ QCOMPARE(provider.playerControl()->media().canonicalUrl(), url3);
+ QCOMPARE(spy.count(), 3);
+}
+
+void tst_QmlAudio::playing()
+{
+ QtTestMediaServiceProvider provider;
+ QDeclarativeAudio audio;
+
+ QSignalSpy playingChangedSpy(&audio, SIGNAL(playingChanged()));
+ QSignalSpy startedSpy(&audio, SIGNAL(started()));
+ QSignalSpy stoppedSpy(&audio, SIGNAL(stopped()));
+
+ int playingChanged = 0;
+ int started = 0;
+ int stopped = 0;
+
+ QCOMPARE(audio.isPlaying(), false);
+
+ // setPlaying(true) when stopped.
+ audio.setPlaying(true);
+ QCOMPARE(audio.isPlaying(), true);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
+ QCOMPARE(playingChangedSpy.count(), ++playingChanged);
+ QCOMPARE(startedSpy.count(), ++started);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // setPlaying(false) when playing.
+ audio.setPlaying(false);
+ QCOMPARE(audio.isPlaying(), false);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
+ QCOMPARE(playingChangedSpy.count(), ++playingChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(stoppedSpy.count(), ++stopped);
+
+ // play() when stopped.
+ audio.play();
+ QCOMPARE(audio.isPlaying(), true);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
+ QCOMPARE(playingChangedSpy.count(), ++playingChanged);
+ QCOMPARE(startedSpy.count(), ++started);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // stop() when playing.
+ audio.stop();
+ QCOMPARE(audio.isPlaying(), false);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
+ QCOMPARE(playingChangedSpy.count(), ++playingChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(stoppedSpy.count(), ++stopped);
+
+ // stop() when stopped.
+ audio.stop();
+ QCOMPARE(audio.isPlaying(), false);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
+ QCOMPARE(playingChangedSpy.count(), playingChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // setPlaying(false) when stopped.
+ audio.setPlaying(false);
+ QCOMPARE(audio.isPlaying(), false);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
+ QCOMPARE(playingChangedSpy.count(), playingChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ audio.setPlaying(true);
+ QCOMPARE(audio.isPlaying(), true);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
+ QCOMPARE(playingChangedSpy.count(), ++playingChanged);
+ QCOMPARE(startedSpy.count(), ++started);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // setPlaying(true) when playing.
+ audio.setPlaying(true);
+ QCOMPARE(audio.isPlaying(), true);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
+ QCOMPARE(playingChangedSpy.count(), playingChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // play() when playing.
+ audio.play();
+ QCOMPARE(audio.isPlaying(), true);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
+ QCOMPARE(playingChangedSpy.count(), playingChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(stoppedSpy.count(), stopped);
+}
+
+void tst_QmlAudio::paused()
+{
+ QtTestMediaServiceProvider provider;
+ QDeclarativeAudio audio;
+
+ QSignalSpy playingChangedSpy(&audio, SIGNAL(playingChanged()));
+ QSignalSpy pausedChangedSpy(&audio, SIGNAL(pausedChanged()));
+ QSignalSpy startedSpy(&audio, SIGNAL(started()));
+ QSignalSpy pausedSpy(&audio, SIGNAL(paused()));
+ QSignalSpy resumedSpy(&audio, SIGNAL(resumed()));
+ QSignalSpy stoppedSpy(&audio, SIGNAL(stopped()));
+
+ int playingChanged = 0;
+ int pausedChanged = 0;
+ int started = 0;
+ int paused = 0;
+ int resumed = 0;
+ int stopped = 0;
+
+ QCOMPARE(audio.isPlaying(), false);
+ QCOMPARE(audio.isPaused(), false);
+
+ // setPlaying(true) when stopped.
+ audio.setPlaying(true);
+ QCOMPARE(audio.isPlaying(), true);
+ QCOMPARE(audio.isPaused(), false);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
+ QCOMPARE(playingChangedSpy.count(), ++playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), pausedChanged);
+ QCOMPARE(startedSpy.count(), ++started);
+ QCOMPARE(pausedSpy.count(), paused);
+ QCOMPARE(resumedSpy.count(), resumed);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // setPaused(true) when playing.
+ audio.setPaused(true);
+ QCOMPARE(audio.isPlaying(), true);
+ QCOMPARE(audio.isPaused(), true);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState);
+ QCOMPARE(playingChangedSpy.count(), playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(pausedSpy.count(), ++paused);
+ QCOMPARE(resumedSpy.count(), resumed);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // setPaused(true) when paused.
+ audio.setPaused(true);
+ QCOMPARE(audio.isPlaying(), true);
+ QCOMPARE(audio.isPaused(), true);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState);
+ QCOMPARE(playingChangedSpy.count(), playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), pausedChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(pausedSpy.count(), paused);
+ QCOMPARE(resumedSpy.count(), resumed);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // pause() when paused.
+ audio.pause();
+ QCOMPARE(audio.isPlaying(), true);
+ QCOMPARE(audio.isPaused(), true);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState);
+ QCOMPARE(playingChangedSpy.count(), playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), pausedChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(pausedSpy.count(), paused);
+ QCOMPARE(resumedSpy.count(), resumed);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // setPaused(false) when paused.
+ audio.setPaused(false);
+ QCOMPARE(audio.isPlaying(), true);
+ QCOMPARE(audio.isPaused(), false);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
+ QCOMPARE(playingChangedSpy.count(), playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(pausedSpy.count(), paused);
+ QCOMPARE(resumedSpy.count(), ++resumed);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // setPaused(false) when playing.
+ audio.setPaused(false);
+ QCOMPARE(audio.isPlaying(), true);
+ QCOMPARE(audio.isPaused(), false);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
+ QCOMPARE(playingChangedSpy.count(), playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), pausedChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(pausedSpy.count(), paused);
+ QCOMPARE(resumedSpy.count(), resumed);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // pause() when playing.
+ audio.pause();
+ QCOMPARE(audio.isPlaying(), true);
+ QCOMPARE(audio.isPaused(), true);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState);
+ QCOMPARE(playingChangedSpy.count(), playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(pausedSpy.count(), ++paused);
+ QCOMPARE(resumedSpy.count(), resumed);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // setPlaying(false) when paused.
+ audio.setPlaying(false);
+ QCOMPARE(audio.isPlaying(), false);
+ QCOMPARE(audio.isPaused(), true);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
+ QCOMPARE(playingChangedSpy.count(), ++playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), pausedChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(pausedSpy.count(), paused);
+ QCOMPARE(resumedSpy.count(), resumed);
+ QCOMPARE(stoppedSpy.count(), ++stopped);
+
+ // setPaused(true) when stopped and paused.
+ audio.setPaused(true);
+ QCOMPARE(audio.isPlaying(), false);
+ QCOMPARE(audio.isPaused(), true);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
+ QCOMPARE(playingChangedSpy.count(), playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), pausedChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(pausedSpy.count(), paused);
+ QCOMPARE(resumedSpy.count(), resumed);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // setPaused(false) when stopped and paused.
+ audio.setPaused(false);
+ QCOMPARE(audio.isPlaying(), false);
+ QCOMPARE(audio.isPaused(), false);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
+ QCOMPARE(playingChangedSpy.count(), playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(pausedSpy.count(), paused);
+ QCOMPARE(resumedSpy.count(), resumed);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // setPaused(true) when stopped.
+ audio.setPaused(true);
+ QCOMPARE(audio.isPlaying(), false);
+ QCOMPARE(audio.isPaused(), true);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
+ QCOMPARE(playingChangedSpy.count(), playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(pausedSpy.count(), paused);
+ QCOMPARE(resumedSpy.count(), resumed);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // setPlaying(true) when stopped and paused.
+ audio.setPlaying(true);
+ QCOMPARE(audio.isPlaying(), true);
+ QCOMPARE(audio.isPaused(), true);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState);
+ QCOMPARE(playingChangedSpy.count(), ++playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), pausedChanged);
+ QCOMPARE(startedSpy.count(), ++started);
+ QCOMPARE(pausedSpy.count(), ++paused);
+ QCOMPARE(resumedSpy.count(), resumed);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // play() when paused.
+ audio.play();
+ QCOMPARE(audio.isPlaying(), true);
+ QCOMPARE(audio.isPaused(), false);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
+ QCOMPARE(playingChangedSpy.count(), playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(pausedSpy.count(), paused);
+ QCOMPARE(resumedSpy.count(), ++resumed);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // setPaused(true) when playing.
+ audio.setPaused(true);
+ QCOMPARE(audio.isPlaying(), true);
+ QCOMPARE(audio.isPaused(), true);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState);
+ QCOMPARE(playingChangedSpy.count(), playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(pausedSpy.count(), ++paused);
+ QCOMPARE(resumedSpy.count(), resumed);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // stop() when paused.
+ audio.stop();
+ QCOMPARE(audio.isPlaying(), false);
+ QCOMPARE(audio.isPaused(), false);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
+ QCOMPARE(playingChangedSpy.count(), ++playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(pausedSpy.count(), paused);
+ QCOMPARE(resumedSpy.count(), resumed);
+ QCOMPARE(stoppedSpy.count(), ++stopped);
+
+ // setPaused(true) when stopped.
+ audio.setPaused(true);
+ QCOMPARE(audio.isPlaying(), false);
+ QCOMPARE(audio.isPaused(), true);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
+ QCOMPARE(playingChangedSpy.count(), playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(pausedSpy.count(), paused);
+ QCOMPARE(resumedSpy.count(), resumed);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // stop() when stopped and paused.
+ audio.stop();
+ QCOMPARE(audio.isPlaying(), false);
+ QCOMPARE(audio.isPaused(), false);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
+ QCOMPARE(playingChangedSpy.count(), playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(pausedSpy.count(), paused);
+ QCOMPARE(resumedSpy.count(), resumed);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // pause() when stopped.
+ audio.pause();
+ QCOMPARE(audio.isPlaying(), true);
+ QCOMPARE(audio.isPaused(), true);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState);
+ QCOMPARE(playingChangedSpy.count(), ++playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
+ QCOMPARE(startedSpy.count(), ++started);
+ QCOMPARE(pausedSpy.count(), ++paused);
+ QCOMPARE(resumedSpy.count(), resumed);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // setPlaying(false) when paused.
+ audio.setPlaying(false);
+ QCOMPARE(audio.isPlaying(), false);
+ QCOMPARE(audio.isPaused(), true);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
+ QCOMPARE(playingChangedSpy.count(), ++playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), pausedChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(pausedSpy.count(), paused);
+ QCOMPARE(resumedSpy.count(), resumed);
+ QCOMPARE(stoppedSpy.count(), ++stopped);
+
+ // pause() when stopped and paused.
+ audio.pause();
+ QCOMPARE(audio.isPlaying(), true);
+ QCOMPARE(audio.isPaused(), true);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState);
+ QCOMPARE(playingChangedSpy.count(), ++playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), pausedChanged);
+ QCOMPARE(startedSpy.count(), ++started);
+ QCOMPARE(pausedSpy.count(), ++paused);
+ QCOMPARE(resumedSpy.count(), resumed);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // setPlaying(false) when paused.
+ audio.setPlaying(false);
+ QCOMPARE(audio.isPlaying(), false);
+ QCOMPARE(audio.isPaused(), true);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
+ QCOMPARE(playingChangedSpy.count(), ++playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), pausedChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(pausedSpy.count(), paused);
+ QCOMPARE(resumedSpy.count(), resumed);
+ QCOMPARE(stoppedSpy.count(), ++stopped);
+
+ // play() when stopped and paused.
+ audio.play();
+ QCOMPARE(audio.isPlaying(), true);
+ QCOMPARE(audio.isPaused(), false);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
+ QCOMPARE(playingChangedSpy.count(), ++playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
+ QCOMPARE(startedSpy.count(), ++started);
+ QCOMPARE(pausedSpy.count(), paused);
+ QCOMPARE(resumedSpy.count(), resumed);
+ QCOMPARE(stoppedSpy.count(), stopped);
+}
+
+void tst_QmlAudio::duration()
+{
+ QtTestMediaServiceProvider provider;
+ QDeclarativeAudio audio;
+
+ QSignalSpy spy(&audio, SIGNAL(durationChanged()));
+
+ QCOMPARE(audio.duration(), 0);
+
+ provider.playerControl()->setDuration(4040);
+ QCOMPARE(audio.duration(), 4040);
+ QCOMPARE(spy.count(), 1);
+
+ provider.playerControl()->setDuration(-129);
+ QCOMPARE(audio.duration(), -129);
+ QCOMPARE(spy.count(), 2);
+
+ provider.playerControl()->setDuration(0);
+ QCOMPARE(audio.duration(), 0);
+ QCOMPARE(spy.count(), 3);
+
+ // Unnecessary duration changed signals aren't filtered.
+ provider.playerControl()->setDuration(0);
+ QCOMPARE(audio.duration(), 0);
+ QCOMPARE(spy.count(), 4);
+}
+
+void tst_QmlAudio::position()
+{
+ QtTestMediaServiceProvider provider;
+ QDeclarativeAudio audio;
+
+ QSignalSpy spy(&audio, SIGNAL(positionChanged()));
+
+ QCOMPARE(audio.position(), 0);
+
+ // QDeclarativeAudio won't bound set positions to the duration. A media service may though.
+ QCOMPARE(audio.duration(), 0);
+
+ audio.setPosition(450);
+ QCOMPARE(audio.position(), 450);
+ QCOMPARE(provider.playerControl()->position(), qint64(450));
+ QCOMPARE(spy.count(), 1);
+
+ audio.setPosition(-5403);
+ QCOMPARE(audio.position(), -5403);
+ QCOMPARE(provider.playerControl()->position(), qint64(-5403));
+ QCOMPARE(spy.count(), 2);
+
+ audio.setPosition(-5403);
+ QCOMPARE(audio.position(), -5403);
+ QCOMPARE(provider.playerControl()->position(), qint64(-5403));
+ QCOMPARE(spy.count(), 3);
+
+ // Check the signal change signal is emitted if the change originates from the media service.
+ provider.playerControl()->setPosition(0);
+ QCOMPARE(audio.position(), 0);
+ QCOMPARE(spy.count(), 4);
+
+ connect(&audio, SIGNAL(positionChanged()), &QTestEventLoop::instance(), SLOT(exitLoop()));
+
+ provider.playerControl()->updateState(QMediaPlayer::PlayingState);
+ QTestEventLoop::instance().enterLoop(1);
+ QVERIFY(spy.count() > 4 && spy.count() < 7); // 5 or 6
+
+ provider.playerControl()->updateState(QMediaPlayer::PausedState);
+ QTestEventLoop::instance().enterLoop(1);
+ QVERIFY(spy.count() < 7);
+}
+
+void tst_QmlAudio::volume()
+{
+ QtTestMediaServiceProvider provider;
+ QDeclarativeAudio audio;
+
+ QSignalSpy spy(&audio, SIGNAL(volumeChanged()));
+
+ QCOMPARE(audio.volume(), qreal(0.5));
+
+ audio.setVolume(0.7);
+ QCOMPARE(audio.volume(), qreal(0.7));
+ QCOMPARE(provider.playerControl()->volume(), 70);
+ QCOMPARE(spy.count(), 1);
+
+ audio.setVolume(0.7);
+ QCOMPARE(audio.volume(), qreal(0.7));
+ QCOMPARE(provider.playerControl()->volume(), 70);
+ QCOMPARE(spy.count(), 2);
+
+ provider.playerControl()->setVolume(30);
+ QCOMPARE(audio.volume(), qreal(0.3));
+ QCOMPARE(spy.count(), 3);
+}
+
+void tst_QmlAudio::muted()
+{
+ QtTestMediaServiceProvider provider;
+ QDeclarativeAudio audio;
+
+ QSignalSpy spy(&audio, SIGNAL(mutedChanged()));
+
+ QCOMPARE(audio.isMuted(), false);
+
+ audio.setMuted(true);
+ QCOMPARE(audio.isMuted(), true);
+ QCOMPARE(provider.playerControl()->isMuted(), true);
+ QCOMPARE(spy.count(), 1);
+
+ provider.playerControl()->setMuted(false);
+ QCOMPARE(audio.isMuted(), false);
+ QCOMPARE(spy.count(), 2);
+
+ audio.setMuted(false);
+ QCOMPARE(audio.isMuted(), false);
+ QCOMPARE(provider.playerControl()->isMuted(), false);
+ QCOMPARE(spy.count(), 3);
+}
+
+void tst_QmlAudio::bufferProgress()
+{
+ QtTestMediaServiceProvider provider;
+ QDeclarativeAudio audio;
+
+ QSignalSpy spy(&audio, SIGNAL(bufferProgressChanged()));
+
+ QCOMPARE(audio.bufferProgress(), qreal(0.0));
+
+ provider.playerControl()->setBufferStatus(20);
+ QCOMPARE(audio.bufferProgress(), qreal(0.2));
+ QCOMPARE(spy.count(), 1);
+
+ provider.playerControl()->setBufferStatus(20);
+ QCOMPARE(audio.bufferProgress(), qreal(0.2));
+ QCOMPARE(spy.count(), 2);
+
+ provider.playerControl()->setBufferStatus(40);
+ QCOMPARE(audio.bufferProgress(), qreal(0.4));
+ QCOMPARE(spy.count(), 3);
+
+ connect(&audio, SIGNAL(positionChanged()), &QTestEventLoop::instance(), SLOT(exitLoop()));
+
+ provider.playerControl()->updateMediaStatus(
+ QMediaPlayer::BufferingMedia, QMediaPlayer::PlayingState);
+ QTestEventLoop::instance().enterLoop(1);
+ QVERIFY(spy.count() > 3 && spy.count() < 6); // 4 or 5
+
+ provider.playerControl()->updateMediaStatus(QMediaPlayer::BufferedMedia);
+ QTestEventLoop::instance().enterLoop(1);
+ QVERIFY(spy.count() < 6);
+}
+
+void tst_QmlAudio::seekable()
+{
+ QtTestMediaServiceProvider provider;
+ QDeclarativeAudio audio;
+
+ QSignalSpy spy(&audio, SIGNAL(seekableChanged()));
+
+ QCOMPARE(audio.isSeekable(), false);
+
+ provider.playerControl()->setSeekable(true);
+ QCOMPARE(audio.isSeekable(), true);
+ QCOMPARE(spy.count(), 1);
+
+ provider.playerControl()->setSeekable(true);
+ QCOMPARE(audio.isSeekable(), true);
+ QCOMPARE(spy.count(), 2);
+
+ provider.playerControl()->setSeekable(false);
+ QCOMPARE(audio.isSeekable(), false);
+ QCOMPARE(spy.count(), 3);
+}
+
+void tst_QmlAudio::playbackRate()
+{
+ QtTestMediaServiceProvider provider;
+ QDeclarativeAudio audio;
+
+ QSignalSpy spy(&audio, SIGNAL(playbackRateChanged()));
+
+ QCOMPARE(audio.playbackRate(), qreal(1.0));
+
+ audio.setPlaybackRate(0.5);
+ QCOMPARE(audio.playbackRate(), qreal(0.5));
+ QCOMPARE(provider.playerControl()->playbackRate(), qreal(0.5));
+ QCOMPARE(spy.count(), 1);
+
+ provider.playerControl()->setPlaybackRate(2.0);
+ QCOMPARE(provider.playerControl()->playbackRate(), qreal(2.0));
+ QCOMPARE(spy.count(), 2);
+
+ audio.setPlaybackRate(2.0);
+ QCOMPARE(audio.playbackRate(), qreal(2.0));
+ QCOMPARE(provider.playerControl()->playbackRate(), qreal(2.0));
+ QCOMPARE(spy.count(), 3);
+}
+
+void tst_QmlAudio::status()
+{
+ QtTestMediaServiceProvider provider;
+ QDeclarativeAudio audio;
+
+ QSignalSpy statusChangedSpy(&audio, SIGNAL(statusChanged()));
+ QSignalSpy loadedSpy(&audio, SIGNAL(loaded()));
+ QSignalSpy bufferingSpy(&audio, SIGNAL(buffering()));
+ QSignalSpy stalledSpy(&audio, SIGNAL(stalled()));
+ QSignalSpy bufferedSpy(&audio, SIGNAL(buffered()));
+ QSignalSpy endOfMediaSpy(&audio, SIGNAL(endOfMedia()));
+
+ QCOMPARE(audio.status(), QDeclarativeAudio::NoMedia);
+
+ // Set media, start loading.
+ provider.playerControl()->updateMediaStatus(QMediaPlayer::LoadingMedia);
+ QCOMPARE(audio.status(), QDeclarativeAudio::Loading);
+ QCOMPARE(statusChangedSpy.count(), 1);
+ QCOMPARE(loadedSpy.count(), 0);
+ QCOMPARE(bufferingSpy.count(), 0);
+ QCOMPARE(stalledSpy.count(), 0);
+ QCOMPARE(bufferedSpy.count(), 0);
+ QCOMPARE(endOfMediaSpy.count(), 0);
+
+ // Finish loading.
+ provider.playerControl()->updateMediaStatus(QMediaPlayer::LoadedMedia);
+ QCOMPARE(audio.status(), QDeclarativeAudio::Loaded);
+ QCOMPARE(statusChangedSpy.count(), 2);
+ QCOMPARE(loadedSpy.count(), 1);
+ QCOMPARE(bufferingSpy.count(), 0);
+ QCOMPARE(stalledSpy.count(), 0);
+ QCOMPARE(bufferedSpy.count(), 0);
+ QCOMPARE(endOfMediaSpy.count(), 0);
+
+ // Play, start buffering.
+ provider.playerControl()->updateMediaStatus(
+ QMediaPlayer::StalledMedia, QMediaPlayer::PlayingState);
+ QCOMPARE(audio.status(), QDeclarativeAudio::Stalled);
+ QCOMPARE(statusChangedSpy.count(), 3);
+ QCOMPARE(loadedSpy.count(), 1);
+ QCOMPARE(bufferingSpy.count(), 0);
+ QCOMPARE(stalledSpy.count(), 1);
+ QCOMPARE(bufferedSpy.count(), 0);
+ QCOMPARE(endOfMediaSpy.count(), 0);
+
+ // Enough data buffered to proceed.
+ provider.playerControl()->updateMediaStatus(QMediaPlayer::BufferingMedia);
+ QCOMPARE(audio.status(), QDeclarativeAudio::Buffering);
+ QCOMPARE(statusChangedSpy.count(), 4);
+ QCOMPARE(loadedSpy.count(), 1);
+ QCOMPARE(bufferingSpy.count(), 1);
+ QCOMPARE(stalledSpy.count(), 1);
+ QCOMPARE(bufferedSpy.count(), 0);
+ QCOMPARE(endOfMediaSpy.count(), 0);
+
+ // Errant second buffering status changed.
+ provider.playerControl()->updateMediaStatus(QMediaPlayer::BufferingMedia);
+ QCOMPARE(audio.status(), QDeclarativeAudio::Buffering);
+ QCOMPARE(statusChangedSpy.count(), 4);
+ QCOMPARE(loadedSpy.count(), 1);
+ QCOMPARE(bufferingSpy.count(), 1);
+ QCOMPARE(stalledSpy.count(), 1);
+ QCOMPARE(bufferedSpy.count(), 0);
+ QCOMPARE(endOfMediaSpy.count(), 0);
+
+ // Buffer full.
+ provider.playerControl()->updateMediaStatus(QMediaPlayer::BufferedMedia);
+ QCOMPARE(audio.status(), QDeclarativeAudio::Buffered);
+ QCOMPARE(statusChangedSpy.count(), 5);
+ QCOMPARE(loadedSpy.count(), 1);
+ QCOMPARE(bufferingSpy.count(), 1);
+ QCOMPARE(stalledSpy.count(), 1);
+ QCOMPARE(bufferedSpy.count(), 1);
+ QCOMPARE(endOfMediaSpy.count(), 0);
+
+ // Buffer getting low.
+ provider.playerControl()->updateMediaStatus(QMediaPlayer::BufferingMedia);
+ QCOMPARE(audio.status(), QDeclarativeAudio::Buffering);
+ QCOMPARE(statusChangedSpy.count(), 6);
+ QCOMPARE(loadedSpy.count(), 1);
+ QCOMPARE(bufferingSpy.count(), 2);
+ QCOMPARE(stalledSpy.count(), 1);
+ QCOMPARE(bufferedSpy.count(), 1);
+ QCOMPARE(endOfMediaSpy.count(), 0);
+
+ // Buffer full.
+ provider.playerControl()->updateMediaStatus(QMediaPlayer::BufferedMedia);
+ QCOMPARE(audio.status(), QDeclarativeAudio::Buffered);
+ QCOMPARE(statusChangedSpy.count(), 7);
+ QCOMPARE(loadedSpy.count(), 1);
+ QCOMPARE(bufferingSpy.count(), 2);
+ QCOMPARE(stalledSpy.count(), 1);
+ QCOMPARE(bufferedSpy.count(), 2);
+ QCOMPARE(endOfMediaSpy.count(), 0);
+
+ // Finished.
+ provider.playerControl()->updateMediaStatus(
+ QMediaPlayer::EndOfMedia, QMediaPlayer::StoppedState);
+ QCOMPARE(audio.status(), QDeclarativeAudio::EndOfMedia);
+ QCOMPARE(statusChangedSpy.count(), 8);
+ QCOMPARE(loadedSpy.count(), 1);
+ QCOMPARE(bufferingSpy.count(), 2);
+ QCOMPARE(stalledSpy.count(), 1);
+ QCOMPARE(bufferedSpy.count(), 2);
+ QCOMPARE(endOfMediaSpy.count(), 1);
+}
+
+void tst_QmlAudio::metaData_data()
+{
+ QTest::addColumn<QByteArray>("propertyName");
+ QTest::addColumn<QtMultimedia::MetaData>("propertyKey");
+ QTest::addColumn<QVariant>("value1");
+ QTest::addColumn<QVariant>("value2");
+
+ QTest::newRow("title")
+ << QByteArray("title")
+ << QtMultimedia::Title
+ << QVariant(QString::fromLatin1("This is a title"))
+ << QVariant(QString::fromLatin1("This is another title"));
+
+ QTest::newRow("genre")
+ << QByteArray("genre")
+ << QtMultimedia::Genre
+ << QVariant(QString::fromLatin1("rock"))
+ << QVariant(QString::fromLatin1("pop"));
+
+ QTest::newRow("trackNumber")
+ << QByteArray("trackNumber")
+ << QtMultimedia::TrackNumber
+ << QVariant(8)
+ << QVariant(12);
+}
+
+void tst_QmlAudio::metaData()
+{
+ QFETCH(QByteArray, propertyName);
+ QFETCH(QtMultimedia::MetaData, propertyKey);
+ QFETCH(QVariant, value1);
+ QFETCH(QVariant, value2);
+
+ QtTestMediaServiceProvider provider;
+ QDeclarativeAudio audio;
+
+ QSignalSpy spy(&audio, SIGNAL(__metaDataChanged()));
+
+ const int index = audio.metaObject()->indexOfProperty(propertyName.constData());
+ QVERIFY(index != -1);
+
+ QMetaProperty property = audio.metaObject()->property(index);
+ QCOMPARE(property.read(&audio), QVariant());
+
+ property.write(&audio, value1);
+ QCOMPARE(property.read(&audio), value1);
+ QCOMPARE(provider.metaDataControl()->metaData(propertyKey), value1);
+ QCOMPARE(spy.count(), 1);
+
+ provider.metaDataControl()->setMetaData(propertyKey, value2);
+ QCOMPARE(property.read(&audio), value2);
+ QCOMPARE(spy.count(), 2);
+}
+
+void tst_QmlAudio::error()
+{
+ const QString errorString = QLatin1String("Failed to open device.");
+
+ QtTestMediaServiceProvider provider;
+ QDeclarativeAudio audio;
+
+ QSignalSpy errorSpy(&audio, SIGNAL(error(QDeclarativeAudio::Error,QString)));
+ QSignalSpy errorChangedSpy(&audio, SIGNAL(errorChanged()));
+
+ QCOMPARE(audio.error(), QDeclarativeAudio::NoError);
+ QCOMPARE(audio.errorString(), QString());
+
+ provider.playerControl()->emitError(QMediaPlayer::ResourceError, errorString);
+
+ QCOMPARE(audio.error(), QDeclarativeAudio::ResourceError);
+ QCOMPARE(audio.errorString(), errorString);
+ QCOMPARE(errorSpy.count(), 1);
+ QCOMPARE(errorChangedSpy.count(), 1);
+
+ // Changing the source resets the error properties.
+ audio.setSource(QUrl("http://example.com"));
+ QCOMPARE(audio.error(), QDeclarativeAudio::NoError);
+ QCOMPARE(audio.errorString(), QString());
+ QCOMPARE(errorSpy.count(), 1);
+ QCOMPARE(errorChangedSpy.count(), 2);
+
+ // But isn't noisy.
+ audio.setSource(QUrl("file:///file/path"));
+ QCOMPARE(audio.error(), QDeclarativeAudio::NoError);
+ QCOMPARE(audio.errorString(), QString());
+ QCOMPARE(errorSpy.count(), 1);
+ QCOMPARE(errorChangedSpy.count(), 2);
+}
+
+
+QTEST_MAIN(tst_QmlAudio)
+
+#include "tst_qdeclarativeaudio.moc"
diff --git a/tests/auto/qdeclarativevideo/qdeclarativevideo.pro b/tests/auto/qdeclarativevideo/qdeclarativevideo.pro
new file mode 100644
index 0000000..d946bb0
--- /dev/null
+++ b/tests/auto/qdeclarativevideo/qdeclarativevideo.pro
@@ -0,0 +1,4 @@
+load(qttest_p4)
+SOURCES += tst_qdeclarativevideo.cpp
+
+QT += multimedia declarative
diff --git a/tests/auto/qdeclarativevideo/tst_qdeclarativevideo.cpp b/tests/auto/qdeclarativevideo/tst_qdeclarativevideo.cpp
new file mode 100644
index 0000000..9fc1e70
--- /dev/null
+++ b/tests/auto/qdeclarativevideo/tst_qdeclarativevideo.cpp
@@ -0,0 +1,911 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+
+#include <QtMultimedia/private/qdeclarativevideo_p.h>
+
+#include <QtGui/qapplication.h>
+#include <QtMultimedia/qabstractvideosurface.h>
+#include <QtMultimedia/qgraphicsvideoitem.h>
+#include <QtMultimedia/qmediaplayercontrol.h>
+#include <QtMultimedia/qmediaservice.h>
+#include <QtMultimedia/qvideooutputcontrol.h>
+#include <QtMultimedia/qvideorenderercontrol.h>
+#include <QtMultimedia/qvideosurfaceformat.h>
+
+
+class tst_QmlGraphicsVideo : public QObject
+{
+ Q_OBJECT
+public slots:
+ void initTestCase();
+
+private slots:
+ void nullPlayerControl();
+ void nullService();
+
+ void playing();
+ void paused();
+ void error();
+
+ void hasAudio();
+ void hasVideo();
+ void fillMode();
+ void geometry();
+};
+
+Q_DECLARE_METATYPE(QtMultimedia::MetaData);
+Q_DECLARE_METATYPE(QDeclarativeVideo::Error);
+
+class QtTestMediaPlayerControl : public QMediaPlayerControl
+{
+ Q_OBJECT
+public:
+ QtTestMediaPlayerControl(QObject *parent = 0)
+ : QMediaPlayerControl(parent)
+ , m_state(QMediaPlayer::StoppedState)
+ , m_mediaStatus(QMediaPlayer::NoMedia)
+ , m_duration(0)
+ , m_position(0)
+ , m_playbackRate(1.0)
+ , m_volume(50)
+ , m_bufferStatus(0)
+ , m_muted(false)
+ , m_audioAvailable(false)
+ , m_videoAvailable(false)
+ , m_seekable(false)
+ {
+ }
+
+ QMediaPlayer::State state() const { return m_state; }
+ void updateState(QMediaPlayer::State state) { emit stateChanged(m_state = state); }
+
+ QMediaPlayer::MediaStatus mediaStatus() const { return m_mediaStatus; }
+ void updateMediaStatus(QMediaPlayer::MediaStatus status) {
+ emit mediaStatusChanged(m_mediaStatus = status); }
+ void updateMediaStatus(QMediaPlayer::MediaStatus status, QMediaPlayer::State state)
+ {
+ m_mediaStatus = status;
+ m_state = state;
+
+ emit mediaStatusChanged(m_mediaStatus);
+ emit stateChanged(m_state);
+ }
+
+ qint64 duration() const { return m_duration; }
+ void setDuration(qint64 duration) { emit durationChanged(m_duration = duration); }
+
+ qint64 position() const { return m_position; }
+ void setPosition(qint64 position) { emit positionChanged(m_position = position); }
+
+ int volume() const { return m_volume; }
+ void setVolume(int volume) { emit volumeChanged(m_volume = volume); }
+
+ bool isMuted() const { return m_muted; }
+ void setMuted(bool muted) { emit mutedChanged(m_muted = muted); }
+
+ int bufferStatus() const { return m_bufferStatus; }
+ void setBufferStatus(int status) { emit bufferStatusChanged(m_bufferStatus = status); }
+
+ bool isAudioAvailable() const { return m_audioAvailable; }
+ void setAudioAvailable(bool available) {
+ emit audioAvailableChanged(m_audioAvailable = available); }
+ bool isVideoAvailable() const { return m_videoAvailable; }
+ void setVideoAvailable(bool available) {
+ emit videoAvailableChanged(m_videoAvailable = available); }
+
+ bool isSeekable() const { return m_seekable; }
+ void setSeekable(bool seekable) { emit seekableChanged(m_seekable = seekable); }
+
+ QMediaTimeRange availablePlaybackRanges() const { return QMediaTimeRange(); }
+
+ qreal playbackRate() const { return m_playbackRate; }
+ void setPlaybackRate(qreal rate) { emit playbackRateChanged(m_playbackRate = rate); }
+
+ QMediaContent media() const { return m_media; }
+ const QIODevice *mediaStream() const { return 0; }
+ void setMedia(const QMediaContent &media, QIODevice *)
+ {
+ m_media = media;
+
+ m_mediaStatus = m_media.isNull()
+ ? QMediaPlayer::NoMedia
+ : QMediaPlayer::LoadingMedia;
+
+ emit mediaChanged(m_media);
+ emit mediaStatusChanged(m_mediaStatus);
+ }
+
+ void play() { emit stateChanged(m_state = QMediaPlayer::PlayingState); }
+ void pause() { emit stateChanged(m_state = QMediaPlayer::PausedState); }
+ void stop() { emit stateChanged(m_state = QMediaPlayer::StoppedState); }
+
+ void emitError(QMediaPlayer::Error err, const QString &errorString) {
+ emit error(err, errorString); }
+
+private:
+ QMediaPlayer::State m_state;
+ QMediaPlayer::MediaStatus m_mediaStatus;
+ qint64 m_duration;
+ qint64 m_position;
+ qreal m_playbackRate;
+ int m_volume;
+ int m_bufferStatus;
+ bool m_muted;
+ bool m_audioAvailable;
+ bool m_videoAvailable;
+ bool m_seekable;
+ QMediaContent m_media;
+};
+
+class QtTestOutputControl : public QVideoOutputControl
+{
+public:
+ QtTestOutputControl(QObject *parent) : QVideoOutputControl(parent), m_output(NoOutput) {}
+
+ QList<Output> availableOutputs() const { return m_outputs; }
+ void setAvailableOutputs(const QList<Output> outputs) { m_outputs = outputs; }
+
+ Output output() const { return m_output; }
+ virtual void setOutput(Output output) { m_output = output; }
+
+private:
+ Output m_output;
+ QList<Output> m_outputs;
+};
+
+class QtTestRendererControl : public QVideoRendererControl
+{
+public:
+ QtTestRendererControl(QObject *parent ) : QVideoRendererControl(parent), m_surface(0) {}
+
+ QAbstractVideoSurface *surface() const { return m_surface; }
+ void setSurface(QAbstractVideoSurface *surface) { m_surface = surface; }
+
+private:
+ QAbstractVideoSurface *m_surface;
+};
+
+class QtTestMediaService : public QMediaService
+{
+ Q_OBJECT
+public:
+ QtTestMediaService(
+ QtTestMediaPlayerControl *playerControl,
+ QtTestOutputControl *outputControl,
+ QtTestRendererControl *rendererControl,
+ QObject *parent)
+ : QMediaService(parent)
+ , playerControl(playerControl)
+ , outputControl(outputControl)
+ , rendererControl(rendererControl)
+ {
+ }
+
+ QMediaControl *control(const char *name) const
+ {
+ if (qstrcmp(name, QMediaPlayerControl_iid) == 0)
+ return playerControl;
+ else if (qstrcmp(name, QVideoOutputControl_iid) == 0)
+ return outputControl;
+ else if (qstrcmp(name, QVideoRendererControl_iid) == 0)
+ return rendererControl;
+ else
+ return 0;
+ }
+
+ QtTestMediaPlayerControl *playerControl;
+ QtTestOutputControl *outputControl;
+ QtTestRendererControl *rendererControl;
+};
+
+class QtTestMediaServiceProvider : public QMediaServiceProvider
+{
+ Q_OBJECT
+public:
+ QtTestMediaServiceProvider()
+ : service(new QtTestMediaService(
+ new QtTestMediaPlayerControl(this),
+ new QtTestOutputControl(this),
+ new QtTestRendererControl(this),
+ this))
+ {
+ setDefaultServiceProvider(this);
+ }
+
+ QtTestMediaServiceProvider(QtTestMediaService *service)
+ : service(service)
+ {
+ setDefaultServiceProvider(this);
+ }
+
+ QtTestMediaServiceProvider(
+ QtTestMediaPlayerControl *playerControl,
+ QtTestOutputControl *outputControl,
+ QtTestRendererControl *rendererControl)
+ : service(new QtTestMediaService(playerControl, outputControl, rendererControl, this))
+ {
+ setDefaultServiceProvider(this);
+ }
+
+ ~QtTestMediaServiceProvider()
+ {
+ setDefaultServiceProvider(0);
+ }
+
+ QMediaService *requestService(
+ const QByteArray &type,
+ const QMediaServiceProviderHint & = QMediaServiceProviderHint())
+ {
+ requestedService = type;
+
+ return service;
+ }
+
+ void releaseService(QMediaService *) {}
+
+ inline QtTestMediaPlayerControl *playerControl() { return service->playerControl; }
+ inline QtTestRendererControl *rendererControl() { return service->rendererControl; }
+
+ QtTestMediaService *service;
+ QByteArray requestedService;
+};
+
+
+void tst_QmlGraphicsVideo::initTestCase()
+{
+ qRegisterMetaType<QDeclarativeVideo::Error>();
+}
+
+void tst_QmlGraphicsVideo::nullPlayerControl()
+{
+ QtTestMediaServiceProvider provider(0, 0, 0);
+
+ QDeclarativeVideo video;
+
+ QCOMPARE(video.source(), QUrl());
+ video.setSource(QUrl("http://example.com"));
+ QCOMPARE(video.source(), QUrl());
+
+ QCOMPARE(video.isPlaying(), false);
+ video.setPlaying(true);
+ QCOMPARE(video.isPlaying(), false);
+ video.play();
+ QCOMPARE(video.isPlaying(), false);
+
+ QCOMPARE(video.isPaused(), false);
+ video.pause();
+ QCOMPARE(video.isPaused(), false);
+ video.setPaused(true);
+ QCOMPARE(video.isPaused(), true);
+
+ QCOMPARE(video.duration(), 0);
+
+ QCOMPARE(video.position(), 0);
+ video.setPosition(10000);
+ QCOMPARE(video.position(), 0);
+
+ QCOMPARE(video.volume(), qreal(0));
+ video.setVolume(50);
+ QCOMPARE(video.volume(), qreal(0));
+
+ QCOMPARE(video.isMuted(), false);
+ video.setMuted(true);
+ QCOMPARE(video.isMuted(), false);
+
+ QCOMPARE(video.bufferProgress(), qreal(0));
+
+ QCOMPARE(video.isSeekable(), false);
+
+ QCOMPARE(video.playbackRate(), qreal(1.0));
+
+ QCOMPARE(video.hasAudio(), false);
+ QCOMPARE(video.hasVideo(), false);
+
+ QCOMPARE(video.status(), QDeclarativeVideo::NoMedia);
+
+ QCOMPARE(video.error(), QDeclarativeVideo::ServiceMissing);
+}
+
+void tst_QmlGraphicsVideo::nullService()
+{
+ QtTestMediaServiceProvider provider(0);
+
+ QDeclarativeVideo video;
+
+ QCOMPARE(video.source(), QUrl());
+ video.setSource(QUrl("http://example.com"));
+ QCOMPARE(video.source(), QUrl());
+
+ QCOMPARE(video.isPlaying(), false);
+ video.setPlaying(true);
+ QCOMPARE(video.isPlaying(), false);
+ video.play();
+ QCOMPARE(video.isPlaying(), false);
+
+ QCOMPARE(video.isPaused(), false);
+ video.pause();
+ QCOMPARE(video.isPaused(), false);
+ video.setPaused(true);
+ QCOMPARE(video.isPaused(), true);
+
+ QCOMPARE(video.duration(), 0);
+
+ QCOMPARE(video.position(), 0);
+ video.setPosition(10000);
+ QCOMPARE(video.position(), 0);
+
+ QCOMPARE(video.volume(), qreal(0));
+ video.setVolume(50);
+ QCOMPARE(video.volume(), qreal(0));
+
+ QCOMPARE(video.isMuted(), false);
+ video.setMuted(true);
+ QCOMPARE(video.isMuted(), false);
+
+ QCOMPARE(video.bufferProgress(), qreal(0));
+
+ QCOMPARE(video.isSeekable(), false);
+
+ QCOMPARE(video.playbackRate(), qreal(1.0));
+
+ QCOMPARE(video.hasAudio(), false);
+ QCOMPARE(video.hasVideo(), false);
+
+ QCOMPARE(video.status(), QDeclarativeVideo::NoMedia);
+
+ QCOMPARE(video.error(), QDeclarativeVideo::ServiceMissing);
+
+ QCOMPARE(video.metaObject()->indexOfProperty("title"), -1);
+ QCOMPARE(video.metaObject()->indexOfProperty("genre"), -1);
+ QCOMPARE(video.metaObject()->indexOfProperty("description"), -1);
+}
+
+void tst_QmlGraphicsVideo::playing()
+{
+ QtTestMediaServiceProvider provider;
+ QDeclarativeVideo video;
+
+ QSignalSpy playingChangedSpy(&video, SIGNAL(playingChanged()));
+ QSignalSpy startedSpy(&video, SIGNAL(started()));
+ QSignalSpy stoppedSpy(&video, SIGNAL(stopped()));
+
+ int playingChanged = 0;
+ int started = 0;
+ int stopped = 0;
+
+ QCOMPARE(video.isPlaying(), false);
+
+ // setPlaying(true) when stopped.
+ video.setPlaying(true);
+ QCOMPARE(video.isPlaying(), true);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
+ QCOMPARE(playingChangedSpy.count(), ++playingChanged);
+ QCOMPARE(startedSpy.count(), ++started);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // setPlaying(false) when playing.
+ video.setPlaying(false);
+ QCOMPARE(video.isPlaying(), false);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
+ QCOMPARE(playingChangedSpy.count(), ++playingChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(stoppedSpy.count(), ++stopped);
+
+ // play() when stopped.
+ video.play();
+ QCOMPARE(video.isPlaying(), true);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
+ QCOMPARE(playingChangedSpy.count(), ++playingChanged);
+ QCOMPARE(startedSpy.count(), ++started);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // stop() when playing.
+ video.stop();
+ QCOMPARE(video.isPlaying(), false);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
+ QCOMPARE(playingChangedSpy.count(), ++playingChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(stoppedSpy.count(), ++stopped);
+
+ // stop() when stopped.
+ video.stop();
+ QCOMPARE(video.isPlaying(), false);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
+ QCOMPARE(playingChangedSpy.count(), playingChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // setPlaying(false) when stopped.
+ video.setPlaying(false);
+ QCOMPARE(video.isPlaying(), false);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
+ QCOMPARE(playingChangedSpy.count(), playingChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ video.setPlaying(true);
+ QCOMPARE(video.isPlaying(), true);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
+ QCOMPARE(playingChangedSpy.count(), ++playingChanged);
+ QCOMPARE(startedSpy.count(), ++started);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // setPlaying(true) when playing.
+ video.setPlaying(true);
+ QCOMPARE(video.isPlaying(), true);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
+ QCOMPARE(playingChangedSpy.count(), playingChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // play() when playing.
+ video.play();
+ QCOMPARE(video.isPlaying(), true);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
+ QCOMPARE(playingChangedSpy.count(), playingChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(stoppedSpy.count(), stopped);
+}
+
+void tst_QmlGraphicsVideo::paused()
+{
+ QtTestMediaServiceProvider provider;
+ QDeclarativeVideo video;
+
+ QSignalSpy playingChangedSpy(&video, SIGNAL(playingChanged()));
+ QSignalSpy pausedChangedSpy(&video, SIGNAL(pausedChanged()));
+ QSignalSpy startedSpy(&video, SIGNAL(started()));
+ QSignalSpy pausedSpy(&video, SIGNAL(paused()));
+ QSignalSpy resumedSpy(&video, SIGNAL(resumed()));
+ QSignalSpy stoppedSpy(&video, SIGNAL(stopped()));
+
+ int playingChanged = 0;
+ int pausedChanged = 0;
+ int started = 0;
+ int paused = 0;
+ int resumed = 0;
+ int stopped = 0;
+
+ QCOMPARE(video.isPlaying(), false);
+ QCOMPARE(video.isPaused(), false);
+
+ // setPlaying(true) when stopped.
+ video.setPlaying(true);
+ QCOMPARE(video.isPlaying(), true);
+ QCOMPARE(video.isPaused(), false);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
+ QCOMPARE(playingChangedSpy.count(), ++playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), pausedChanged);
+ QCOMPARE(startedSpy.count(), ++started);
+ QCOMPARE(pausedSpy.count(), paused);
+ QCOMPARE(resumedSpy.count(), resumed);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // setPaused(true) when playing.
+ video.setPaused(true);
+ QCOMPARE(video.isPlaying(), true);
+ QCOMPARE(video.isPaused(), true);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState);
+ QCOMPARE(playingChangedSpy.count(), playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(pausedSpy.count(), ++paused);
+ QCOMPARE(resumedSpy.count(), resumed);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // setPaused(true) when paused.
+ video.setPaused(true);
+ QCOMPARE(video.isPlaying(), true);
+ QCOMPARE(video.isPaused(), true);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState);
+ QCOMPARE(playingChangedSpy.count(), playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), pausedChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(pausedSpy.count(), paused);
+ QCOMPARE(resumedSpy.count(), resumed);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // pause() when paused.
+ video.pause();
+ QCOMPARE(video.isPlaying(), true);
+ QCOMPARE(video.isPaused(), true);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState);
+ QCOMPARE(playingChangedSpy.count(), playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), pausedChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(pausedSpy.count(), paused);
+ QCOMPARE(resumedSpy.count(), resumed);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // setPaused(false) when paused.
+ video.setPaused(false);
+ QCOMPARE(video.isPlaying(), true);
+ QCOMPARE(video.isPaused(), false);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
+ QCOMPARE(playingChangedSpy.count(), playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(pausedSpy.count(), paused);
+ QCOMPARE(resumedSpy.count(), ++resumed);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // setPaused(false) when playing.
+ video.setPaused(false);
+ QCOMPARE(video.isPlaying(), true);
+ QCOMPARE(video.isPaused(), false);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
+ QCOMPARE(playingChangedSpy.count(), playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), pausedChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(pausedSpy.count(), paused);
+ QCOMPARE(resumedSpy.count(), resumed);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // pause() when playing.
+ video.pause();
+ QCOMPARE(video.isPlaying(), true);
+ QCOMPARE(video.isPaused(), true);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState);
+ QCOMPARE(playingChangedSpy.count(), playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(pausedSpy.count(), ++paused);
+ QCOMPARE(resumedSpy.count(), resumed);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // setPlaying(false) when paused.
+ video.setPlaying(false);
+ QCOMPARE(video.isPlaying(), false);
+ QCOMPARE(video.isPaused(), true);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
+ QCOMPARE(playingChangedSpy.count(), ++playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), pausedChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(pausedSpy.count(), paused);
+ QCOMPARE(resumedSpy.count(), resumed);
+ QCOMPARE(stoppedSpy.count(), ++stopped);
+
+ // setPaused(true) when stopped and paused.
+ video.setPaused(true);
+ QCOMPARE(video.isPlaying(), false);
+ QCOMPARE(video.isPaused(), true);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
+ QCOMPARE(playingChangedSpy.count(), playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), pausedChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(pausedSpy.count(), paused);
+ QCOMPARE(resumedSpy.count(), resumed);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // setPaused(false) when stopped and paused.
+ video.setPaused(false);
+ QCOMPARE(video.isPlaying(), false);
+ QCOMPARE(video.isPaused(), false);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
+ QCOMPARE(playingChangedSpy.count(), playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(pausedSpy.count(), paused);
+ QCOMPARE(resumedSpy.count(), resumed);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // setPaused(true) when stopped.
+ video.setPaused(true);
+ QCOMPARE(video.isPlaying(), false);
+ QCOMPARE(video.isPaused(), true);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
+ QCOMPARE(playingChangedSpy.count(), playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(pausedSpy.count(), paused);
+ QCOMPARE(resumedSpy.count(), resumed);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // setPlaying(true) when stopped and paused.
+ video.setPlaying(true);
+ QCOMPARE(video.isPlaying(), true);
+ QCOMPARE(video.isPaused(), true);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState);
+ QCOMPARE(playingChangedSpy.count(), ++playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), pausedChanged);
+ QCOMPARE(startedSpy.count(), ++started);
+ QCOMPARE(pausedSpy.count(), ++paused);
+ QCOMPARE(resumedSpy.count(), resumed);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // play() when paused.
+ video.play();
+ QCOMPARE(video.isPlaying(), true);
+ QCOMPARE(video.isPaused(), false);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
+ QCOMPARE(playingChangedSpy.count(), playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(pausedSpy.count(), paused);
+ QCOMPARE(resumedSpy.count(), ++resumed);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // setPaused(true) when playing.
+ video.setPaused(true);
+ QCOMPARE(video.isPlaying(), true);
+ QCOMPARE(video.isPaused(), true);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState);
+ QCOMPARE(playingChangedSpy.count(), playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(pausedSpy.count(), ++paused);
+ QCOMPARE(resumedSpy.count(), resumed);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // stop() when paused.
+ video.stop();
+ QCOMPARE(video.isPlaying(), false);
+ QCOMPARE(video.isPaused(), false);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
+ QCOMPARE(playingChangedSpy.count(), ++playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(pausedSpy.count(), paused);
+ QCOMPARE(resumedSpy.count(), resumed);
+ QCOMPARE(stoppedSpy.count(), ++stopped);
+
+ // setPaused(true) when stopped.
+ video.setPaused(true);
+ QCOMPARE(video.isPlaying(), false);
+ QCOMPARE(video.isPaused(), true);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
+ QCOMPARE(playingChangedSpy.count(), playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(pausedSpy.count(), paused);
+ QCOMPARE(resumedSpy.count(), resumed);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // stop() when stopped and paused.
+ video.stop();
+ QCOMPARE(video.isPlaying(), false);
+ QCOMPARE(video.isPaused(), false);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
+ QCOMPARE(playingChangedSpy.count(), playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(pausedSpy.count(), paused);
+ QCOMPARE(resumedSpy.count(), resumed);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // pause() when stopped.
+ video.pause();
+ QCOMPARE(video.isPlaying(), true);
+ QCOMPARE(video.isPaused(), true);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState);
+ QCOMPARE(playingChangedSpy.count(), ++playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
+ QCOMPARE(startedSpy.count(), ++started);
+ QCOMPARE(pausedSpy.count(), ++paused);
+ QCOMPARE(resumedSpy.count(), resumed);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // setPlaying(false) when paused.
+ video.setPlaying(false);
+ QCOMPARE(video.isPlaying(), false);
+ QCOMPARE(video.isPaused(), true);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
+ QCOMPARE(playingChangedSpy.count(), ++playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), pausedChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(pausedSpy.count(), paused);
+ QCOMPARE(resumedSpy.count(), resumed);
+ QCOMPARE(stoppedSpy.count(), ++stopped);
+
+ // pause() when stopped and paused.
+ video.pause();
+ QCOMPARE(video.isPlaying(), true);
+ QCOMPARE(video.isPaused(), true);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState);
+ QCOMPARE(playingChangedSpy.count(), ++playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), pausedChanged);
+ QCOMPARE(startedSpy.count(), ++started);
+ QCOMPARE(pausedSpy.count(), ++paused);
+ QCOMPARE(resumedSpy.count(), resumed);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // setPlaying(false) when paused.
+ video.setPlaying(false);
+ QCOMPARE(video.isPlaying(), false);
+ QCOMPARE(video.isPaused(), true);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
+ QCOMPARE(playingChangedSpy.count(), ++playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), pausedChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(pausedSpy.count(), paused);
+ QCOMPARE(resumedSpy.count(), resumed);
+ QCOMPARE(stoppedSpy.count(), ++stopped);
+
+ // play() when stopped and paused.
+ video.play();
+ QCOMPARE(video.isPlaying(), true);
+ QCOMPARE(video.isPaused(), false);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
+ QCOMPARE(playingChangedSpy.count(), ++playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
+ QCOMPARE(startedSpy.count(), ++started);
+ QCOMPARE(pausedSpy.count(), paused);
+ QCOMPARE(resumedSpy.count(), resumed);
+ QCOMPARE(stoppedSpy.count(), stopped);
+}
+
+void tst_QmlGraphicsVideo::error()
+{
+ const QString errorString = QLatin1String("Failed to open device.");
+
+ QtTestMediaServiceProvider provider;
+ QDeclarativeVideo video;
+
+ QSignalSpy errorSpy(&video, SIGNAL(error(QDeclarativeVideo::Error,QString)));
+ QSignalSpy errorChangedSpy(&video, SIGNAL(errorChanged()));
+
+ QCOMPARE(video.error(), QDeclarativeVideo::NoError);
+ QCOMPARE(video.errorString(), QString());
+
+ provider.playerControl()->emitError(QMediaPlayer::ResourceError, errorString);
+
+ QCOMPARE(video.error(), QDeclarativeVideo::ResourceError);
+ QCOMPARE(video.errorString(), errorString);
+ QCOMPARE(errorSpy.count(), 1);
+ QCOMPARE(errorChangedSpy.count(), 1);
+
+ // Changing the source resets the error properties.
+ video.setSource(QUrl("http://example.com"));
+ QCOMPARE(video.error(), QDeclarativeVideo::NoError);
+ QCOMPARE(video.errorString(), QString());
+ QCOMPARE(errorSpy.count(), 1);
+ QCOMPARE(errorChangedSpy.count(), 2);
+
+ // But isn't noisy.
+ video.setSource(QUrl("file:///file/path"));
+ QCOMPARE(video.error(), QDeclarativeVideo::NoError);
+ QCOMPARE(video.errorString(), QString());
+ QCOMPARE(errorSpy.count(), 1);
+ QCOMPARE(errorChangedSpy.count(), 2);
+}
+
+
+void tst_QmlGraphicsVideo::hasAudio()
+{
+ QtTestMediaServiceProvider provider;
+ QDeclarativeVideo video;
+
+ QSignalSpy spy(&video, SIGNAL(hasAudioChanged()));
+
+ QCOMPARE(video.hasAudio(), false);
+
+ provider.playerControl()->setAudioAvailable(true);
+ QCOMPARE(video.hasAudio(), true);
+ QCOMPARE(spy.count(), 1);
+
+ provider.playerControl()->setAudioAvailable(true);
+ QCOMPARE(video.hasAudio(), true);
+ QCOMPARE(spy.count(), 2);
+
+ provider.playerControl()->setAudioAvailable(false);
+ QCOMPARE(video.hasAudio(), false);
+ QCOMPARE(spy.count(), 3);
+}
+
+void tst_QmlGraphicsVideo::hasVideo()
+{
+ QtTestMediaServiceProvider provider;
+ QDeclarativeVideo video;
+
+ QSignalSpy spy(&video, SIGNAL(hasVideoChanged()));
+
+ QCOMPARE(video.hasVideo(), false);
+
+ provider.playerControl()->setVideoAvailable(true);
+ QCOMPARE(video.hasVideo(), true);
+ QCOMPARE(spy.count(), 1);
+
+ provider.playerControl()->setVideoAvailable(true);
+ QCOMPARE(video.hasVideo(), true);
+ QCOMPARE(spy.count(), 2);
+
+ provider.playerControl()->setVideoAvailable(false);
+ QCOMPARE(video.hasVideo(), false);
+ QCOMPARE(spy.count(), 3);
+}
+
+void tst_QmlGraphicsVideo::fillMode()
+{
+ QtTestMediaServiceProvider provider;
+ QDeclarativeVideo video;
+
+ QList<QGraphicsItem *> children = video.childItems();
+ QCOMPARE(children.count(), 1);
+ QGraphicsVideoItem *videoItem = qgraphicsitem_cast<QGraphicsVideoItem *>(children.first());
+ QVERIFY(videoItem != 0);
+
+ QCOMPARE(video.fillMode(), QDeclarativeVideo::PreserveAspectFit);
+
+ video.setFillMode(QDeclarativeVideo::PreserveAspectCrop);
+ QCOMPARE(video.fillMode(), QDeclarativeVideo::PreserveAspectCrop);
+ QCOMPARE(videoItem->aspectRatioMode(), Qt::KeepAspectRatioByExpanding);
+
+ video.setFillMode(QDeclarativeVideo::Stretch);
+ QCOMPARE(video.fillMode(), QDeclarativeVideo::Stretch);
+ QCOMPARE(videoItem->aspectRatioMode(), Qt::IgnoreAspectRatio);
+
+ video.setFillMode(QDeclarativeVideo::PreserveAspectFit);
+ QCOMPARE(video.fillMode(), QDeclarativeVideo::PreserveAspectFit);
+ QCOMPARE(videoItem->aspectRatioMode(), Qt::KeepAspectRatio);
+}
+
+void tst_QmlGraphicsVideo::geometry()
+{
+ QtTestMediaServiceProvider provider;
+ QDeclarativeVideo video;
+
+ QAbstractVideoSurface *surface = provider.rendererControl()->surface();
+ QVERIFY(surface != 0);
+
+ QList<QGraphicsItem *> children = video.childItems();
+ QCOMPARE(children.count(), 1);
+ QGraphicsVideoItem *videoItem = qgraphicsitem_cast<QGraphicsVideoItem *>(children.first());
+ QVERIFY(videoItem != 0);
+
+ QVideoSurfaceFormat format(QSize(640, 480), QVideoFrame::Format_RGB32);
+
+ QVERIFY(surface->start(format));
+
+ QCOMPARE(video.implicitWidth(), qreal(640));
+ QCOMPARE(video.implicitHeight(), qreal(480));
+
+ video.setWidth(560);
+ video.setHeight(328);
+
+ QCOMPARE(videoItem->size().width(), qreal(560));
+ QCOMPARE(videoItem->size().height(), qreal(328));
+}
+
+QTEST_MAIN(tst_QmlGraphicsVideo)
+
+#include "tst_qdeclarativevideo.moc"
diff --git a/tests/auto/qeasingcurve/tst_qeasingcurve.cpp b/tests/auto/qeasingcurve/tst_qeasingcurve.cpp
index 12ddff1..124f900 100644
--- a/tests/auto/qeasingcurve/tst_qeasingcurve.cpp
+++ b/tests/auto/qeasingcurve/tst_qeasingcurve.cpp
@@ -69,6 +69,8 @@ private slots:
void valueForProgress();
void setCustomType();
void operators();
+ void properties();
+ void metaTypes();
protected:
};
@@ -505,6 +507,65 @@ void tst_QEasingCurve::operators()
QVERIFY(curve2 == curve);
}
+class tst_QEasingProperties : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QEasingCurve easing READ easing WRITE setEasing)
+public:
+ tst_QEasingProperties(QObject *parent = 0) : QObject(parent) {}
+
+ QEasingCurve easing() const { return e; }
+ void setEasing(const QEasingCurve& value) { e = value; }
+
+private:
+ QEasingCurve e;
+};
+
+// Test getting and setting easing properties via the metaobject system.
+void tst_QEasingCurve::properties()
+{
+ tst_QEasingProperties obj;
+
+ QEasingCurve inOutBack(QEasingCurve::InOutBack);
+ qreal overshoot = 1.5f;
+ inOutBack.setOvershoot(overshoot);
+ qreal amplitude = inOutBack.amplitude();
+ qreal period = inOutBack.period();
+
+ obj.setEasing(inOutBack);
+
+ QEasingCurve easing = qVariantValue<QEasingCurve>(obj.property("easing"));
+ QCOMPARE(easing.type(), QEasingCurve::InOutBack);
+ QCOMPARE(easing.overshoot(), overshoot);
+ QCOMPARE(easing.amplitude(), amplitude);
+ QCOMPARE(easing.period(), period);
+
+ QEasingCurve linear(QEasingCurve::Linear);
+ overshoot = linear.overshoot();
+ amplitude = linear.amplitude();
+ period = linear.period();
+
+ obj.setProperty("easing",
+ qVariantFromValue(QEasingCurve(QEasingCurve::Linear)));
+
+ easing = qVariantValue<QEasingCurve>(obj.property("easing"));
+ QCOMPARE(easing.type(), QEasingCurve::Linear);
+ QCOMPARE(easing.overshoot(), overshoot);
+ QCOMPARE(easing.amplitude(), amplitude);
+ QCOMPARE(easing.period(), period);
+}
+
+void tst_QEasingCurve::metaTypes()
+{
+ QVERIFY(QMetaType::type("QEasingCurve") == QMetaType::QEasingCurve);
+
+ QCOMPARE(QByteArray(QMetaType::typeName(QMetaType::QEasingCurve)),
+ QByteArray("QEasingCurve"));
+
+ QVERIFY(QMetaType::isRegistered(QMetaType::QEasingCurve));
+
+ QVERIFY(qMetaTypeId<QEasingCurve>() == QMetaType::QEasingCurve);
+}
QTEST_MAIN(tst_QEasingCurve)
#include "tst_qeasingcurve.moc"
diff --git a/tests/auto/qmlaudio/qmlaudio.pro b/tests/auto/qmlaudio/qmlaudio.pro
deleted file mode 100644
index fe18761..0000000
--- a/tests/auto/qmlaudio/qmlaudio.pro
+++ /dev/null
@@ -1,6 +0,0 @@
-load(qttest_p4)
-SOURCES += tst_qmlaudio.cpp
-
-QT += multimedia declarative
-requires(contains(QT_CONFIG, multimedia))
-requires(contains(QT_CONFIG, declarative))
diff --git a/tests/auto/qmlaudio/tst_qmlaudio.cpp b/tests/auto/qmlaudio/tst_qmlaudio.cpp
deleted file mode 100644
index 068317f..0000000
--- a/tests/auto/qmlaudio/tst_qmlaudio.cpp
+++ /dev/null
@@ -1,1200 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtTest/QtTest>
-
-#include <QtMultimedia/private/qmlaudio_p.h>
-
-#include <QtGui/qapplication.h>
-#include <QtMultimedia/qmediaplayercontrol.h>
-#include <QtMultimedia/qmediaservice.h>
-#include <QtMultimedia/qmetadatacontrol.h>
-
-
-class tst_QmlAudio : public QObject
-{
- Q_OBJECT
-public slots:
- void initTestCase();
-
-private slots:
- void nullPlayerControl();
- void nullMetaDataControl();
- void nullService();
-
- void source();
- void playing();
- void paused();
- void duration();
- void position();
- void volume();
- void muted();
- void bufferProgress();
- void seekable();
- void playbackRate();
- void status();
- void metaData_data();
- void metaData();
- void error();
-};
-
-Q_DECLARE_METATYPE(QtMultimedia::MetaData);
-Q_DECLARE_METATYPE(QmlAudio::Error);
-
-class QtTestMediaPlayerControl : public QMediaPlayerControl
-{
- Q_OBJECT
-public:
- QtTestMediaPlayerControl(QObject *parent = 0)
- : QMediaPlayerControl(parent)
- , m_state(QMediaPlayer::StoppedState)
- , m_mediaStatus(QMediaPlayer::NoMedia)
- , m_duration(0)
- , m_position(0)
- , m_playbackRate(1.0)
- , m_volume(50)
- , m_bufferStatus(0)
- , m_muted(false)
- , m_audioAvailable(false)
- , m_videoAvailable(false)
- , m_seekable(false)
- {
- }
-
- QMediaPlayer::State state() const { return m_state; }
- void updateState(QMediaPlayer::State state) { emit stateChanged(m_state = state); }
-
- QMediaPlayer::MediaStatus mediaStatus() const { return m_mediaStatus; }
- void updateMediaStatus(QMediaPlayer::MediaStatus status) {
- emit mediaStatusChanged(m_mediaStatus = status); }
- void updateMediaStatus(QMediaPlayer::MediaStatus status, QMediaPlayer::State state)
- {
- m_mediaStatus = status;
- m_state = state;
-
- emit mediaStatusChanged(m_mediaStatus);
- emit stateChanged(m_state);
- }
-
- qint64 duration() const { return m_duration; }
- void setDuration(qint64 duration) { emit durationChanged(m_duration = duration); }
-
- qint64 position() const { return m_position; }
- void setPosition(qint64 position) { emit positionChanged(m_position = position); }
-
- int volume() const { return m_volume; }
- void setVolume(int volume) { emit volumeChanged(m_volume = volume); }
-
- bool isMuted() const { return m_muted; }
- void setMuted(bool muted) { emit mutedChanged(m_muted = muted); }
-
- int bufferStatus() const { return m_bufferStatus; }
- void setBufferStatus(int status) { emit bufferStatusChanged(m_bufferStatus = status); }
-
- bool isAudioAvailable() const { return m_audioAvailable; }
- void setAudioAvailable(bool available) {
- emit audioAvailableChanged(m_audioAvailable = available); }
- bool isVideoAvailable() const { return m_videoAvailable; }
- void setVideoAvailable(bool available) {
- emit videoAvailableChanged(m_videoAvailable = available); }
-
- bool isSeekable() const { return m_seekable; }
- void setSeekable(bool seekable) { emit seekableChanged(m_seekable = seekable); }
-
- QMediaTimeRange availablePlaybackRanges() const { return QMediaTimeRange(); }
-
- qreal playbackRate() const { return m_playbackRate; }
- void setPlaybackRate(qreal rate) { emit playbackRateChanged(m_playbackRate = rate); }
-
- QMediaContent media() const { return m_media; }
- const QIODevice *mediaStream() const { return 0; }
- void setMedia(const QMediaContent &media, QIODevice *)
- {
- m_media = media;
-
- m_mediaStatus = m_media.isNull()
- ? QMediaPlayer::NoMedia
- : QMediaPlayer::LoadingMedia;
-
- emit mediaChanged(m_media);
- emit mediaStatusChanged(m_mediaStatus);
- }
-
- void play() { emit stateChanged(m_state = QMediaPlayer::PlayingState); }
- void pause() { emit stateChanged(m_state = QMediaPlayer::PausedState); }
- void stop() { emit stateChanged(m_state = QMediaPlayer::StoppedState); }
-
- void emitError(QMediaPlayer::Error err, const QString &errorString) {
- emit error(err, errorString); }
-
-private:
- QMediaPlayer::State m_state;
- QMediaPlayer::MediaStatus m_mediaStatus;
- qint64 m_duration;
- qint64 m_position;
- qreal m_playbackRate;
- int m_volume;
- int m_bufferStatus;
- bool m_muted;
- bool m_audioAvailable;
- bool m_videoAvailable;
- bool m_seekable;
- QMediaContent m_media;
-};
-
-class QtTestMetaDataControl : public QMetaDataControl
-{
- Q_OBJECT
-public:
- QtTestMetaDataControl(QObject *parent = 0)
- : QMetaDataControl(parent)
- {
- }
-
- bool isWritable() const { return true; }
- bool isMetaDataAvailable() const { return true; }
-
- QVariant metaData(QtMultimedia::MetaData key) const { return m_metaData.value(key); }
- void setMetaData(QtMultimedia::MetaData key, const QVariant &value) {
- m_metaData.insert(key, value); emit metaDataChanged(); }
- void setMetaData(const QMap<QtMultimedia::MetaData, QVariant> &metaData) {
- m_metaData = metaData; emit metaDataChanged(); }
-
- QList<QtMultimedia::MetaData> availableMetaData() const { return m_metaData.keys(); }
-
- QVariant extendedMetaData(const QString &) const { return QVariant(); }
- void setExtendedMetaData(const QString &, const QVariant &) {}
- QStringList availableExtendedMetaData() const { return QStringList(); }
-
-private:
- QMap<QtMultimedia::MetaData, QVariant> m_metaData;
-};
-
-class QtTestMediaService : public QMediaService
-{
- Q_OBJECT
-public:
- QtTestMediaService(
- QtTestMediaPlayerControl *playerControl,
- QtTestMetaDataControl *metaDataControl,
- QObject *parent)
- : QMediaService(parent)
- , playerControl(playerControl)
- , metaDataControl(metaDataControl)
- {
- }
-
- QMediaControl *control(const char *name) const
- {
- if (qstrcmp(name, QMediaPlayerControl_iid) == 0)
- return playerControl;
- else if (qstrcmp(name, QMetaDataControl_iid) == 0)
- return metaDataControl;
- else
- return 0;
- }
-
- QtTestMediaPlayerControl *playerControl;
- QtTestMetaDataControl *metaDataControl;
-};
-
-class QtTestMediaServiceProvider : public QMediaServiceProvider
-{
- Q_OBJECT
-public:
- QtTestMediaServiceProvider()
- : service(new QtTestMediaService(
- new QtTestMediaPlayerControl(this), new QtTestMetaDataControl(this), this))
- {
- setDefaultServiceProvider(this);
- }
-
- QtTestMediaServiceProvider(QtTestMediaService *service)
- : service(service)
- {
- setDefaultServiceProvider(this);
- }
-
- QtTestMediaServiceProvider(
- QtTestMediaPlayerControl *playerControl, QtTestMetaDataControl *metaDataControl)
- : service(new QtTestMediaService(playerControl, metaDataControl, this))
- {
- setDefaultServiceProvider(this);
- }
-
- ~QtTestMediaServiceProvider()
- {
- setDefaultServiceProvider(0);
- }
-
- QMediaService *requestService(
- const QByteArray &type,
- const QMediaServiceProviderHint & = QMediaServiceProviderHint())
- {
- requestedService = type;
-
- return service;
- }
-
- void releaseService(QMediaService *) {}
-
- inline QtTestMediaPlayerControl *playerControl() { return service->playerControl; }
- inline QtTestMetaDataControl *metaDataControl() { return service->metaDataControl; }
-
- QtTestMediaService *service;
- QByteArray requestedService;
-};
-
-
-void tst_QmlAudio::initTestCase()
-{
- qRegisterMetaType<QmlAudio::Error>();
-}
-
-void tst_QmlAudio::nullPlayerControl()
-{
- QtTestMetaDataControl metaDataControl;
- QtTestMediaServiceProvider provider(0, &metaDataControl);
-
- QmlAudio audio;
-
- QCOMPARE(audio.source(), QUrl());
- audio.setSource(QUrl("http://example.com"));
- QCOMPARE(audio.source(), QUrl());
-
- QCOMPARE(audio.isPlaying(), false);
- audio.setPlaying(true);
- QCOMPARE(audio.isPlaying(), false);
- audio.play();
- QCOMPARE(audio.isPlaying(), false);
-
- QCOMPARE(audio.isPaused(), false);
- audio.pause();
- QCOMPARE(audio.isPaused(), false);
- audio.setPaused(true);
- QCOMPARE(audio.isPaused(), true);
-
- QCOMPARE(audio.duration(), 0);
-
- QCOMPARE(audio.position(), 0);
- audio.setPosition(10000);
- QCOMPARE(audio.position(), 0);
-
- QCOMPARE(audio.volume(), qreal(0));
- audio.setVolume(50);
- QCOMPARE(audio.volume(), qreal(0));
-
- QCOMPARE(audio.isMuted(), false);
- audio.setMuted(true);
- QCOMPARE(audio.isMuted(), false);
-
- QCOMPARE(audio.bufferProgress(), qreal(0));
-
- QCOMPARE(audio.isSeekable(), false);
-
- QCOMPARE(audio.playbackRate(), qreal(1.0));
-
- QCOMPARE(audio.status(), QmlAudio::NoMedia);
-
- QCOMPARE(audio.error(), QmlAudio::ServiceMissing);
-}
-
-void tst_QmlAudio::nullMetaDataControl()
-{
- QtTestMediaPlayerControl playerControl;
- QtTestMediaServiceProvider provider(&playerControl, 0);
-
- QmlAudio audio;
-
- QCOMPARE(audio.metaObject()->indexOfProperty("title"), -1);
- QCOMPARE(audio.metaObject()->indexOfProperty("genre"), -1);
- QCOMPARE(audio.metaObject()->indexOfProperty("description"), -1);
-}
-
-void tst_QmlAudio::nullService()
-{
- QtTestMediaServiceProvider provider(0);
-
- QmlAudio audio;
-
- QCOMPARE(audio.source(), QUrl());
- audio.setSource(QUrl("http://example.com"));
- QCOMPARE(audio.source(), QUrl());
-
- QCOMPARE(audio.isPlaying(), false);
- audio.setPlaying(true);
- QCOMPARE(audio.isPlaying(), false);
- audio.play();
- QCOMPARE(audio.isPlaying(), false);
-
- QCOMPARE(audio.isPaused(), false);
- audio.pause();
- QCOMPARE(audio.isPaused(), false);
- audio.setPaused(true);
- QCOMPARE(audio.isPaused(), true);
-
- QCOMPARE(audio.duration(), 0);
-
- QCOMPARE(audio.position(), 0);
- audio.setPosition(10000);
- QCOMPARE(audio.position(), 0);
-
- QCOMPARE(audio.volume(), qreal(0));
- audio.setVolume(50);
- QCOMPARE(audio.volume(), qreal(0));
-
- QCOMPARE(audio.isMuted(), false);
- audio.setMuted(true);
- QCOMPARE(audio.isMuted(), false);
-
- QCOMPARE(audio.bufferProgress(), qreal(0));
-
- QCOMPARE(audio.isSeekable(), false);
-
- QCOMPARE(audio.playbackRate(), qreal(1.0));
-
- QCOMPARE(audio.status(), QmlAudio::NoMedia);
-
- QCOMPARE(audio.error(), QmlAudio::ServiceMissing);
-
- QCOMPARE(audio.metaObject()->indexOfProperty("title"), -1);
- QCOMPARE(audio.metaObject()->indexOfProperty("genre"), -1);
- QCOMPARE(audio.metaObject()->indexOfProperty("description"), -1);
-}
-
-void tst_QmlAudio::source()
-{
- const QUrl url1("http://example.com");
- const QUrl url2("file:///local/path");
- const QUrl url3;
-
- QtTestMediaServiceProvider provider;
- QmlAudio audio;
-
- QSignalSpy spy(&audio, SIGNAL(sourceChanged()));
-
- audio.setSource(url1);
- QCOMPARE(audio.source(), url1);
- QCOMPARE(provider.playerControl()->media().canonicalUrl(), url1);
- QCOMPARE(spy.count(), 1);
-
- audio.setSource(url2);
- QCOMPARE(audio.source(), url2);
- QCOMPARE(provider.playerControl()->media().canonicalUrl(), url2);
- QCOMPARE(spy.count(), 2);
-
- audio.setSource(url3);
- QCOMPARE(audio.source(), url3);
- QCOMPARE(provider.playerControl()->media().canonicalUrl(), url3);
- QCOMPARE(spy.count(), 3);
-}
-
-void tst_QmlAudio::playing()
-{
- QtTestMediaServiceProvider provider;
- QmlAudio audio;
-
- QSignalSpy playingChangedSpy(&audio, SIGNAL(playingChanged()));
- QSignalSpy startedSpy(&audio, SIGNAL(started()));
- QSignalSpy stoppedSpy(&audio, SIGNAL(stopped()));
-
- int playingChanged = 0;
- int started = 0;
- int stopped = 0;
-
- QCOMPARE(audio.isPlaying(), false);
-
- // setPlaying(true) when stopped.
- audio.setPlaying(true);
- QCOMPARE(audio.isPlaying(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
- QCOMPARE(playingChangedSpy.count(), ++playingChanged);
- QCOMPARE(startedSpy.count(), ++started);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // setPlaying(false) when playing.
- audio.setPlaying(false);
- QCOMPARE(audio.isPlaying(), false);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
- QCOMPARE(playingChangedSpy.count(), ++playingChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(stoppedSpy.count(), ++stopped);
-
- // play() when stopped.
- audio.play();
- QCOMPARE(audio.isPlaying(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
- QCOMPARE(playingChangedSpy.count(), ++playingChanged);
- QCOMPARE(startedSpy.count(), ++started);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // stop() when playing.
- audio.stop();
- QCOMPARE(audio.isPlaying(), false);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
- QCOMPARE(playingChangedSpy.count(), ++playingChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(stoppedSpy.count(), ++stopped);
-
- // stop() when stopped.
- audio.stop();
- QCOMPARE(audio.isPlaying(), false);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // setPlaying(false) when stopped.
- audio.setPlaying(false);
- QCOMPARE(audio.isPlaying(), false);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- audio.setPlaying(true);
- QCOMPARE(audio.isPlaying(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
- QCOMPARE(playingChangedSpy.count(), ++playingChanged);
- QCOMPARE(startedSpy.count(), ++started);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // setPlaying(true) when playing.
- audio.setPlaying(true);
- QCOMPARE(audio.isPlaying(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // play() when playing.
- audio.play();
- QCOMPARE(audio.isPlaying(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(stoppedSpy.count(), stopped);
-}
-
-void tst_QmlAudio::paused()
-{
- QtTestMediaServiceProvider provider;
- QmlAudio audio;
-
- QSignalSpy playingChangedSpy(&audio, SIGNAL(playingChanged()));
- QSignalSpy pausedChangedSpy(&audio, SIGNAL(pausedChanged()));
- QSignalSpy startedSpy(&audio, SIGNAL(started()));
- QSignalSpy pausedSpy(&audio, SIGNAL(paused()));
- QSignalSpy resumedSpy(&audio, SIGNAL(resumed()));
- QSignalSpy stoppedSpy(&audio, SIGNAL(stopped()));
-
- int playingChanged = 0;
- int pausedChanged = 0;
- int started = 0;
- int paused = 0;
- int resumed = 0;
- int stopped = 0;
-
- QCOMPARE(audio.isPlaying(), false);
- QCOMPARE(audio.isPaused(), false);
-
- // setPlaying(true) when stopped.
- audio.setPlaying(true);
- QCOMPARE(audio.isPlaying(), true);
- QCOMPARE(audio.isPaused(), false);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
- QCOMPARE(playingChangedSpy.count(), ++playingChanged);
- QCOMPARE(pausedChangedSpy.count(), pausedChanged);
- QCOMPARE(startedSpy.count(), ++started);
- QCOMPARE(pausedSpy.count(), paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // setPaused(true) when playing.
- audio.setPaused(true);
- QCOMPARE(audio.isPlaying(), true);
- QCOMPARE(audio.isPaused(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), ++paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // setPaused(true) when paused.
- audio.setPaused(true);
- QCOMPARE(audio.isPlaying(), true);
- QCOMPARE(audio.isPaused(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(pausedChangedSpy.count(), pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // pause() when paused.
- audio.pause();
- QCOMPARE(audio.isPlaying(), true);
- QCOMPARE(audio.isPaused(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(pausedChangedSpy.count(), pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // setPaused(false) when paused.
- audio.setPaused(false);
- QCOMPARE(audio.isPlaying(), true);
- QCOMPARE(audio.isPaused(), false);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), paused);
- QCOMPARE(resumedSpy.count(), ++resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // setPaused(false) when playing.
- audio.setPaused(false);
- QCOMPARE(audio.isPlaying(), true);
- QCOMPARE(audio.isPaused(), false);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(pausedChangedSpy.count(), pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // pause() when playing.
- audio.pause();
- QCOMPARE(audio.isPlaying(), true);
- QCOMPARE(audio.isPaused(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), ++paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // setPlaying(false) when paused.
- audio.setPlaying(false);
- QCOMPARE(audio.isPlaying(), false);
- QCOMPARE(audio.isPaused(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
- QCOMPARE(playingChangedSpy.count(), ++playingChanged);
- QCOMPARE(pausedChangedSpy.count(), pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), ++stopped);
-
- // setPaused(true) when stopped and paused.
- audio.setPaused(true);
- QCOMPARE(audio.isPlaying(), false);
- QCOMPARE(audio.isPaused(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(pausedChangedSpy.count(), pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // setPaused(false) when stopped and paused.
- audio.setPaused(false);
- QCOMPARE(audio.isPlaying(), false);
- QCOMPARE(audio.isPaused(), false);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // setPaused(true) when stopped.
- audio.setPaused(true);
- QCOMPARE(audio.isPlaying(), false);
- QCOMPARE(audio.isPaused(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // setPlaying(true) when stopped and paused.
- audio.setPlaying(true);
- QCOMPARE(audio.isPlaying(), true);
- QCOMPARE(audio.isPaused(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState);
- QCOMPARE(playingChangedSpy.count(), ++playingChanged);
- QCOMPARE(pausedChangedSpy.count(), pausedChanged);
- QCOMPARE(startedSpy.count(), ++started);
- QCOMPARE(pausedSpy.count(), ++paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // play() when paused.
- audio.play();
- QCOMPARE(audio.isPlaying(), true);
- QCOMPARE(audio.isPaused(), false);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), paused);
- QCOMPARE(resumedSpy.count(), ++resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // setPaused(true) when playing.
- audio.setPaused(true);
- QCOMPARE(audio.isPlaying(), true);
- QCOMPARE(audio.isPaused(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), ++paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // stop() when paused.
- audio.stop();
- QCOMPARE(audio.isPlaying(), false);
- QCOMPARE(audio.isPaused(), false);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
- QCOMPARE(playingChangedSpy.count(), ++playingChanged);
- QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), ++stopped);
-
- // setPaused(true) when stopped.
- audio.setPaused(true);
- QCOMPARE(audio.isPlaying(), false);
- QCOMPARE(audio.isPaused(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // stop() when stopped and paused.
- audio.stop();
- QCOMPARE(audio.isPlaying(), false);
- QCOMPARE(audio.isPaused(), false);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // pause() when stopped.
- audio.pause();
- QCOMPARE(audio.isPlaying(), true);
- QCOMPARE(audio.isPaused(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState);
- QCOMPARE(playingChangedSpy.count(), ++playingChanged);
- QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
- QCOMPARE(startedSpy.count(), ++started);
- QCOMPARE(pausedSpy.count(), ++paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // setPlaying(false) when paused.
- audio.setPlaying(false);
- QCOMPARE(audio.isPlaying(), false);
- QCOMPARE(audio.isPaused(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
- QCOMPARE(playingChangedSpy.count(), ++playingChanged);
- QCOMPARE(pausedChangedSpy.count(), pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), ++stopped);
-
- // pause() when stopped and paused.
- audio.pause();
- QCOMPARE(audio.isPlaying(), true);
- QCOMPARE(audio.isPaused(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState);
- QCOMPARE(playingChangedSpy.count(), ++playingChanged);
- QCOMPARE(pausedChangedSpy.count(), pausedChanged);
- QCOMPARE(startedSpy.count(), ++started);
- QCOMPARE(pausedSpy.count(), ++paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // setPlaying(false) when paused.
- audio.setPlaying(false);
- QCOMPARE(audio.isPlaying(), false);
- QCOMPARE(audio.isPaused(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
- QCOMPARE(playingChangedSpy.count(), ++playingChanged);
- QCOMPARE(pausedChangedSpy.count(), pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), ++stopped);
-
- // play() when stopped and paused.
- audio.play();
- QCOMPARE(audio.isPlaying(), true);
- QCOMPARE(audio.isPaused(), false);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
- QCOMPARE(playingChangedSpy.count(), ++playingChanged);
- QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
- QCOMPARE(startedSpy.count(), ++started);
- QCOMPARE(pausedSpy.count(), paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-}
-
-void tst_QmlAudio::duration()
-{
- QtTestMediaServiceProvider provider;
- QmlAudio audio;
-
- QSignalSpy spy(&audio, SIGNAL(durationChanged()));
-
- QCOMPARE(audio.duration(), 0);
-
- provider.playerControl()->setDuration(4040);
- QCOMPARE(audio.duration(), 4040);
- QCOMPARE(spy.count(), 1);
-
- provider.playerControl()->setDuration(-129);
- QCOMPARE(audio.duration(), -129);
- QCOMPARE(spy.count(), 2);
-
- provider.playerControl()->setDuration(0);
- QCOMPARE(audio.duration(), 0);
- QCOMPARE(spy.count(), 3);
-
- // Unnecessary duration changed signals aren't filtered.
- provider.playerControl()->setDuration(0);
- QCOMPARE(audio.duration(), 0);
- QCOMPARE(spy.count(), 4);
-}
-
-void tst_QmlAudio::position()
-{
- QtTestMediaServiceProvider provider;
- QmlAudio audio;
-
- QSignalSpy spy(&audio, SIGNAL(positionChanged()));
-
- QCOMPARE(audio.position(), 0);
-
- // QmlAudio won't bound set positions to the duration. A media service may though.
- QCOMPARE(audio.duration(), 0);
-
- audio.setPosition(450);
- QCOMPARE(audio.position(), 450);
- QCOMPARE(provider.playerControl()->position(), qint64(450));
- QCOMPARE(spy.count(), 1);
-
- audio.setPosition(-5403);
- QCOMPARE(audio.position(), -5403);
- QCOMPARE(provider.playerControl()->position(), qint64(-5403));
- QCOMPARE(spy.count(), 2);
-
- audio.setPosition(-5403);
- QCOMPARE(audio.position(), -5403);
- QCOMPARE(provider.playerControl()->position(), qint64(-5403));
- QCOMPARE(spy.count(), 3);
-
- // Check the signal change signal is emitted if the change originates from the media service.
- provider.playerControl()->setPosition(0);
- QCOMPARE(audio.position(), 0);
- QCOMPARE(spy.count(), 4);
-
- connect(&audio, SIGNAL(positionChanged()), &QTestEventLoop::instance(), SLOT(exitLoop()));
-
- provider.playerControl()->updateState(QMediaPlayer::PlayingState);
- QTestEventLoop::instance().enterLoop(1);
- QVERIFY(spy.count() > 4 && spy.count() < 7); // 5 or 6
-
- provider.playerControl()->updateState(QMediaPlayer::PausedState);
- QTestEventLoop::instance().enterLoop(1);
- QVERIFY(spy.count() < 7);
-}
-
-void tst_QmlAudio::volume()
-{
- QtTestMediaServiceProvider provider;
- QmlAudio audio;
-
- QSignalSpy spy(&audio, SIGNAL(volumeChanged()));
-
- QCOMPARE(audio.volume(), qreal(0.5));
-
- audio.setVolume(0.7);
- QCOMPARE(audio.volume(), qreal(0.7));
- QCOMPARE(provider.playerControl()->volume(), 70);
- QCOMPARE(spy.count(), 1);
-
- audio.setVolume(0.7);
- QCOMPARE(audio.volume(), qreal(0.7));
- QCOMPARE(provider.playerControl()->volume(), 70);
- QCOMPARE(spy.count(), 2);
-
- provider.playerControl()->setVolume(30);
- QCOMPARE(audio.volume(), qreal(0.3));
- QCOMPARE(spy.count(), 3);
-}
-
-void tst_QmlAudio::muted()
-{
- QtTestMediaServiceProvider provider;
- QmlAudio audio;
-
- QSignalSpy spy(&audio, SIGNAL(mutedChanged()));
-
- QCOMPARE(audio.isMuted(), false);
-
- audio.setMuted(true);
- QCOMPARE(audio.isMuted(), true);
- QCOMPARE(provider.playerControl()->isMuted(), true);
- QCOMPARE(spy.count(), 1);
-
- provider.playerControl()->setMuted(false);
- QCOMPARE(audio.isMuted(), false);
- QCOMPARE(spy.count(), 2);
-
- audio.setMuted(false);
- QCOMPARE(audio.isMuted(), false);
- QCOMPARE(provider.playerControl()->isMuted(), false);
- QCOMPARE(spy.count(), 3);
-}
-
-void tst_QmlAudio::bufferProgress()
-{
- QtTestMediaServiceProvider provider;
- QmlAudio audio;
-
- QSignalSpy spy(&audio, SIGNAL(bufferProgressChanged()));
-
- QCOMPARE(audio.bufferProgress(), qreal(0.0));
-
- provider.playerControl()->setBufferStatus(20);
- QCOMPARE(audio.bufferProgress(), qreal(0.2));
- QCOMPARE(spy.count(), 1);
-
- provider.playerControl()->setBufferStatus(20);
- QCOMPARE(audio.bufferProgress(), qreal(0.2));
- QCOMPARE(spy.count(), 2);
-
- provider.playerControl()->setBufferStatus(40);
- QCOMPARE(audio.bufferProgress(), qreal(0.4));
- QCOMPARE(spy.count(), 3);
-
- connect(&audio, SIGNAL(positionChanged()), &QTestEventLoop::instance(), SLOT(exitLoop()));
-
- provider.playerControl()->updateMediaStatus(
- QMediaPlayer::BufferingMedia, QMediaPlayer::PlayingState);
- QTestEventLoop::instance().enterLoop(1);
- QVERIFY(spy.count() > 3 && spy.count() < 6); // 4 or 5
-
- provider.playerControl()->updateMediaStatus(QMediaPlayer::BufferedMedia);
- QTestEventLoop::instance().enterLoop(1);
- QVERIFY(spy.count() < 6);
-}
-
-void tst_QmlAudio::seekable()
-{
- QtTestMediaServiceProvider provider;
- QmlAudio audio;
-
- QSignalSpy spy(&audio, SIGNAL(seekableChanged()));
-
- QCOMPARE(audio.isSeekable(), false);
-
- provider.playerControl()->setSeekable(true);
- QCOMPARE(audio.isSeekable(), true);
- QCOMPARE(spy.count(), 1);
-
- provider.playerControl()->setSeekable(true);
- QCOMPARE(audio.isSeekable(), true);
- QCOMPARE(spy.count(), 2);
-
- provider.playerControl()->setSeekable(false);
- QCOMPARE(audio.isSeekable(), false);
- QCOMPARE(spy.count(), 3);
-}
-
-void tst_QmlAudio::playbackRate()
-{
- QtTestMediaServiceProvider provider;
- QmlAudio audio;
-
- QSignalSpy spy(&audio, SIGNAL(playbackRateChanged()));
-
- QCOMPARE(audio.playbackRate(), qreal(1.0));
-
- audio.setPlaybackRate(0.5);
- QCOMPARE(audio.playbackRate(), qreal(0.5));
- QCOMPARE(provider.playerControl()->playbackRate(), qreal(0.5));
- QCOMPARE(spy.count(), 1);
-
- provider.playerControl()->setPlaybackRate(2.0);
- QCOMPARE(provider.playerControl()->playbackRate(), qreal(2.0));
- QCOMPARE(spy.count(), 2);
-
- audio.setPlaybackRate(2.0);
- QCOMPARE(audio.playbackRate(), qreal(2.0));
- QCOMPARE(provider.playerControl()->playbackRate(), qreal(2.0));
- QCOMPARE(spy.count(), 3);
-}
-
-void tst_QmlAudio::status()
-{
- QtTestMediaServiceProvider provider;
- QmlAudio audio;
-
- QSignalSpy statusChangedSpy(&audio, SIGNAL(statusChanged()));
- QSignalSpy loadedSpy(&audio, SIGNAL(loaded()));
- QSignalSpy bufferingSpy(&audio, SIGNAL(buffering()));
- QSignalSpy stalledSpy(&audio, SIGNAL(stalled()));
- QSignalSpy bufferedSpy(&audio, SIGNAL(buffered()));
- QSignalSpy endOfMediaSpy(&audio, SIGNAL(endOfMedia()));
-
- QCOMPARE(audio.status(), QmlAudio::NoMedia);
-
- // Set media, start loading.
- provider.playerControl()->updateMediaStatus(QMediaPlayer::LoadingMedia);
- QCOMPARE(audio.status(), QmlAudio::Loading);
- QCOMPARE(statusChangedSpy.count(), 1);
- QCOMPARE(loadedSpy.count(), 0);
- QCOMPARE(bufferingSpy.count(), 0);
- QCOMPARE(stalledSpy.count(), 0);
- QCOMPARE(bufferedSpy.count(), 0);
- QCOMPARE(endOfMediaSpy.count(), 0);
-
- // Finish loading.
- provider.playerControl()->updateMediaStatus(QMediaPlayer::LoadedMedia);
- QCOMPARE(audio.status(), QmlAudio::Loaded);
- QCOMPARE(statusChangedSpy.count(), 2);
- QCOMPARE(loadedSpy.count(), 1);
- QCOMPARE(bufferingSpy.count(), 0);
- QCOMPARE(stalledSpy.count(), 0);
- QCOMPARE(bufferedSpy.count(), 0);
- QCOMPARE(endOfMediaSpy.count(), 0);
-
- // Play, start buffering.
- provider.playerControl()->updateMediaStatus(
- QMediaPlayer::StalledMedia, QMediaPlayer::PlayingState);
- QCOMPARE(audio.status(), QmlAudio::Stalled);
- QCOMPARE(statusChangedSpy.count(), 3);
- QCOMPARE(loadedSpy.count(), 1);
- QCOMPARE(bufferingSpy.count(), 0);
- QCOMPARE(stalledSpy.count(), 1);
- QCOMPARE(bufferedSpy.count(), 0);
- QCOMPARE(endOfMediaSpy.count(), 0);
-
- // Enough data buffered to proceed.
- provider.playerControl()->updateMediaStatus(QMediaPlayer::BufferingMedia);
- QCOMPARE(audio.status(), QmlAudio::Buffering);
- QCOMPARE(statusChangedSpy.count(), 4);
- QCOMPARE(loadedSpy.count(), 1);
- QCOMPARE(bufferingSpy.count(), 1);
- QCOMPARE(stalledSpy.count(), 1);
- QCOMPARE(bufferedSpy.count(), 0);
- QCOMPARE(endOfMediaSpy.count(), 0);
-
- // Errant second buffering status changed.
- provider.playerControl()->updateMediaStatus(QMediaPlayer::BufferingMedia);
- QCOMPARE(audio.status(), QmlAudio::Buffering);
- QCOMPARE(statusChangedSpy.count(), 4);
- QCOMPARE(loadedSpy.count(), 1);
- QCOMPARE(bufferingSpy.count(), 1);
- QCOMPARE(stalledSpy.count(), 1);
- QCOMPARE(bufferedSpy.count(), 0);
- QCOMPARE(endOfMediaSpy.count(), 0);
-
- // Buffer full.
- provider.playerControl()->updateMediaStatus(QMediaPlayer::BufferedMedia);
- QCOMPARE(audio.status(), QmlAudio::Buffered);
- QCOMPARE(statusChangedSpy.count(), 5);
- QCOMPARE(loadedSpy.count(), 1);
- QCOMPARE(bufferingSpy.count(), 1);
- QCOMPARE(stalledSpy.count(), 1);
- QCOMPARE(bufferedSpy.count(), 1);
- QCOMPARE(endOfMediaSpy.count(), 0);
-
- // Buffer getting low.
- provider.playerControl()->updateMediaStatus(QMediaPlayer::BufferingMedia);
- QCOMPARE(audio.status(), QmlAudio::Buffering);
- QCOMPARE(statusChangedSpy.count(), 6);
- QCOMPARE(loadedSpy.count(), 1);
- QCOMPARE(bufferingSpy.count(), 2);
- QCOMPARE(stalledSpy.count(), 1);
- QCOMPARE(bufferedSpy.count(), 1);
- QCOMPARE(endOfMediaSpy.count(), 0);
-
- // Buffer full.
- provider.playerControl()->updateMediaStatus(QMediaPlayer::BufferedMedia);
- QCOMPARE(audio.status(), QmlAudio::Buffered);
- QCOMPARE(statusChangedSpy.count(), 7);
- QCOMPARE(loadedSpy.count(), 1);
- QCOMPARE(bufferingSpy.count(), 2);
- QCOMPARE(stalledSpy.count(), 1);
- QCOMPARE(bufferedSpy.count(), 2);
- QCOMPARE(endOfMediaSpy.count(), 0);
-
- // Finished.
- provider.playerControl()->updateMediaStatus(
- QMediaPlayer::EndOfMedia, QMediaPlayer::StoppedState);
- QCOMPARE(audio.status(), QmlAudio::EndOfMedia);
- QCOMPARE(statusChangedSpy.count(), 8);
- QCOMPARE(loadedSpy.count(), 1);
- QCOMPARE(bufferingSpy.count(), 2);
- QCOMPARE(stalledSpy.count(), 1);
- QCOMPARE(bufferedSpy.count(), 2);
- QCOMPARE(endOfMediaSpy.count(), 1);
-}
-
-void tst_QmlAudio::metaData_data()
-{
- QTest::addColumn<QByteArray>("propertyName");
- QTest::addColumn<QtMultimedia::MetaData>("propertyKey");
- QTest::addColumn<QVariant>("value1");
- QTest::addColumn<QVariant>("value2");
-
- QTest::newRow("title")
- << QByteArray("title")
- << QtMultimedia::Title
- << QVariant(QString::fromLatin1("This is a title"))
- << QVariant(QString::fromLatin1("This is another title"));
-
- QTest::newRow("genre")
- << QByteArray("genre")
- << QtMultimedia::Genre
- << QVariant(QString::fromLatin1("rock"))
- << QVariant(QString::fromLatin1("pop"));
-
- QTest::newRow("trackNumber")
- << QByteArray("trackNumber")
- << QtMultimedia::TrackNumber
- << QVariant(8)
- << QVariant(12);
-}
-
-void tst_QmlAudio::metaData()
-{
- QFETCH(QByteArray, propertyName);
- QFETCH(QtMultimedia::MetaData, propertyKey);
- QFETCH(QVariant, value1);
- QFETCH(QVariant, value2);
-
- QtTestMediaServiceProvider provider;
- QmlAudio audio;
-
- QSignalSpy spy(&audio, SIGNAL(__metaDataChanged()));
-
- const int index = audio.metaObject()->indexOfProperty(propertyName.constData());
- QVERIFY(index != -1);
-
- QMetaProperty property = audio.metaObject()->property(index);
- QCOMPARE(property.read(&audio), QVariant());
-
- property.write(&audio, value1);
- QCOMPARE(property.read(&audio), value1);
- QCOMPARE(provider.metaDataControl()->metaData(propertyKey), value1);
- QCOMPARE(spy.count(), 1);
-
- provider.metaDataControl()->setMetaData(propertyKey, value2);
- QCOMPARE(property.read(&audio), value2);
- QCOMPARE(spy.count(), 2);
-}
-
-void tst_QmlAudio::error()
-{
- const QString errorString = QLatin1String("Failed to open device.");
-
- QtTestMediaServiceProvider provider;
- QmlAudio audio;
-
- QSignalSpy errorSpy(&audio, SIGNAL(error(QmlAudio::Error,QString)));
- QSignalSpy errorChangedSpy(&audio, SIGNAL(errorChanged()));
-
- QCOMPARE(audio.error(), QmlAudio::NoError);
- QCOMPARE(audio.errorString(), QString());
-
- provider.playerControl()->emitError(QMediaPlayer::ResourceError, errorString);
-
- QCOMPARE(audio.error(), QmlAudio::ResourceError);
- QCOMPARE(audio.errorString(), errorString);
- QCOMPARE(errorSpy.count(), 1);
- QCOMPARE(errorChangedSpy.count(), 1);
-
- // Changing the source resets the error properties.
- audio.setSource(QUrl("http://example.com"));
- QCOMPARE(audio.error(), QmlAudio::NoError);
- QCOMPARE(audio.errorString(), QString());
- QCOMPARE(errorSpy.count(), 1);
- QCOMPARE(errorChangedSpy.count(), 2);
-
- // But isn't noisy.
- audio.setSource(QUrl("file:///file/path"));
- QCOMPARE(audio.error(), QmlAudio::NoError);
- QCOMPARE(audio.errorString(), QString());
- QCOMPARE(errorSpy.count(), 1);
- QCOMPARE(errorChangedSpy.count(), 2);
-}
-
-
-QTEST_MAIN(tst_QmlAudio)
-
-#include "tst_qmlaudio.moc"
diff --git a/tests/auto/qmlgraphicsvideo/qmlgraphicsvideo.pro b/tests/auto/qmlgraphicsvideo/qmlgraphicsvideo.pro
deleted file mode 100644
index 0a83124..0000000
--- a/tests/auto/qmlgraphicsvideo/qmlgraphicsvideo.pro
+++ /dev/null
@@ -1,6 +0,0 @@
-load(qttest_p4)
-SOURCES += tst_qmlgraphicsvideo.cpp
-
-QT += multimedia declarative
-requires(contains(QT_CONFIG, multimedia))
-requires(contains(QT_CONFIG, declarative))
diff --git a/tests/auto/qmlgraphicsvideo/tst_qmlgraphicsvideo.cpp b/tests/auto/qmlgraphicsvideo/tst_qmlgraphicsvideo.cpp
deleted file mode 100644
index 0da094d..0000000
--- a/tests/auto/qmlgraphicsvideo/tst_qmlgraphicsvideo.cpp
+++ /dev/null
@@ -1,911 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtTest/QtTest>
-
-#include <QtMultimedia/private/qmlgraphicsvideo_p.h>
-
-#include <QtGui/qapplication.h>
-#include <QtMultimedia/qabstractvideosurface.h>
-#include <QtMultimedia/qgraphicsvideoitem.h>
-#include <QtMultimedia/qmediaplayercontrol.h>
-#include <QtMultimedia/qmediaservice.h>
-#include <QtMultimedia/qvideooutputcontrol.h>
-#include <QtMultimedia/qvideorenderercontrol.h>
-#include <QtMultimedia/qvideosurfaceformat.h>
-
-
-class tst_QmlGraphicsVideo : public QObject
-{
- Q_OBJECT
-public slots:
- void initTestCase();
-
-private slots:
- void nullPlayerControl();
- void nullService();
-
- void playing();
- void paused();
- void error();
-
- void hasAudio();
- void hasVideo();
- void fillMode();
- void geometry();
-};
-
-Q_DECLARE_METATYPE(QtMultimedia::MetaData);
-Q_DECLARE_METATYPE(QmlGraphicsVideo::Error);
-
-class QtTestMediaPlayerControl : public QMediaPlayerControl
-{
- Q_OBJECT
-public:
- QtTestMediaPlayerControl(QObject *parent = 0)
- : QMediaPlayerControl(parent)
- , m_state(QMediaPlayer::StoppedState)
- , m_mediaStatus(QMediaPlayer::NoMedia)
- , m_duration(0)
- , m_position(0)
- , m_playbackRate(1.0)
- , m_volume(50)
- , m_bufferStatus(0)
- , m_muted(false)
- , m_audioAvailable(false)
- , m_videoAvailable(false)
- , m_seekable(false)
- {
- }
-
- QMediaPlayer::State state() const { return m_state; }
- void updateState(QMediaPlayer::State state) { emit stateChanged(m_state = state); }
-
- QMediaPlayer::MediaStatus mediaStatus() const { return m_mediaStatus; }
- void updateMediaStatus(QMediaPlayer::MediaStatus status) {
- emit mediaStatusChanged(m_mediaStatus = status); }
- void updateMediaStatus(QMediaPlayer::MediaStatus status, QMediaPlayer::State state)
- {
- m_mediaStatus = status;
- m_state = state;
-
- emit mediaStatusChanged(m_mediaStatus);
- emit stateChanged(m_state);
- }
-
- qint64 duration() const { return m_duration; }
- void setDuration(qint64 duration) { emit durationChanged(m_duration = duration); }
-
- qint64 position() const { return m_position; }
- void setPosition(qint64 position) { emit positionChanged(m_position = position); }
-
- int volume() const { return m_volume; }
- void setVolume(int volume) { emit volumeChanged(m_volume = volume); }
-
- bool isMuted() const { return m_muted; }
- void setMuted(bool muted) { emit mutedChanged(m_muted = muted); }
-
- int bufferStatus() const { return m_bufferStatus; }
- void setBufferStatus(int status) { emit bufferStatusChanged(m_bufferStatus = status); }
-
- bool isAudioAvailable() const { return m_audioAvailable; }
- void setAudioAvailable(bool available) {
- emit audioAvailableChanged(m_audioAvailable = available); }
- bool isVideoAvailable() const { return m_videoAvailable; }
- void setVideoAvailable(bool available) {
- emit videoAvailableChanged(m_videoAvailable = available); }
-
- bool isSeekable() const { return m_seekable; }
- void setSeekable(bool seekable) { emit seekableChanged(m_seekable = seekable); }
-
- QMediaTimeRange availablePlaybackRanges() const { return QMediaTimeRange(); }
-
- qreal playbackRate() const { return m_playbackRate; }
- void setPlaybackRate(qreal rate) { emit playbackRateChanged(m_playbackRate = rate); }
-
- QMediaContent media() const { return m_media; }
- const QIODevice *mediaStream() const { return 0; }
- void setMedia(const QMediaContent &media, QIODevice *)
- {
- m_media = media;
-
- m_mediaStatus = m_media.isNull()
- ? QMediaPlayer::NoMedia
- : QMediaPlayer::LoadingMedia;
-
- emit mediaChanged(m_media);
- emit mediaStatusChanged(m_mediaStatus);
- }
-
- void play() { emit stateChanged(m_state = QMediaPlayer::PlayingState); }
- void pause() { emit stateChanged(m_state = QMediaPlayer::PausedState); }
- void stop() { emit stateChanged(m_state = QMediaPlayer::StoppedState); }
-
- void emitError(QMediaPlayer::Error err, const QString &errorString) {
- emit error(err, errorString); }
-
-private:
- QMediaPlayer::State m_state;
- QMediaPlayer::MediaStatus m_mediaStatus;
- qint64 m_duration;
- qint64 m_position;
- qreal m_playbackRate;
- int m_volume;
- int m_bufferStatus;
- bool m_muted;
- bool m_audioAvailable;
- bool m_videoAvailable;
- bool m_seekable;
- QMediaContent m_media;
-};
-
-class QtTestOutputControl : public QVideoOutputControl
-{
-public:
- QtTestOutputControl(QObject *parent) : QVideoOutputControl(parent), m_output(NoOutput) {}
-
- QList<Output> availableOutputs() const { return m_outputs; }
- void setAvailableOutputs(const QList<Output> outputs) { m_outputs = outputs; }
-
- Output output() const { return m_output; }
- virtual void setOutput(Output output) { m_output = output; }
-
-private:
- Output m_output;
- QList<Output> m_outputs;
-};
-
-class QtTestRendererControl : public QVideoRendererControl
-{
-public:
- QtTestRendererControl(QObject *parent ) : QVideoRendererControl(parent), m_surface(0) {}
-
- QAbstractVideoSurface *surface() const { return m_surface; }
- void setSurface(QAbstractVideoSurface *surface) { m_surface = surface; }
-
-private:
- QAbstractVideoSurface *m_surface;
-};
-
-class QtTestMediaService : public QMediaService
-{
- Q_OBJECT
-public:
- QtTestMediaService(
- QtTestMediaPlayerControl *playerControl,
- QtTestOutputControl *outputControl,
- QtTestRendererControl *rendererControl,
- QObject *parent)
- : QMediaService(parent)
- , playerControl(playerControl)
- , outputControl(outputControl)
- , rendererControl(rendererControl)
- {
- }
-
- QMediaControl *control(const char *name) const
- {
- if (qstrcmp(name, QMediaPlayerControl_iid) == 0)
- return playerControl;
- else if (qstrcmp(name, QVideoOutputControl_iid) == 0)
- return outputControl;
- else if (qstrcmp(name, QVideoRendererControl_iid) == 0)
- return rendererControl;
- else
- return 0;
- }
-
- QtTestMediaPlayerControl *playerControl;
- QtTestOutputControl *outputControl;
- QtTestRendererControl *rendererControl;
-};
-
-class QtTestMediaServiceProvider : public QMediaServiceProvider
-{
- Q_OBJECT
-public:
- QtTestMediaServiceProvider()
- : service(new QtTestMediaService(
- new QtTestMediaPlayerControl(this),
- new QtTestOutputControl(this),
- new QtTestRendererControl(this),
- this))
- {
- setDefaultServiceProvider(this);
- }
-
- QtTestMediaServiceProvider(QtTestMediaService *service)
- : service(service)
- {
- setDefaultServiceProvider(this);
- }
-
- QtTestMediaServiceProvider(
- QtTestMediaPlayerControl *playerControl,
- QtTestOutputControl *outputControl,
- QtTestRendererControl *rendererControl)
- : service(new QtTestMediaService(playerControl, outputControl, rendererControl, this))
- {
- setDefaultServiceProvider(this);
- }
-
- ~QtTestMediaServiceProvider()
- {
- setDefaultServiceProvider(0);
- }
-
- QMediaService *requestService(
- const QByteArray &type,
- const QMediaServiceProviderHint & = QMediaServiceProviderHint())
- {
- requestedService = type;
-
- return service;
- }
-
- void releaseService(QMediaService *) {}
-
- inline QtTestMediaPlayerControl *playerControl() { return service->playerControl; }
- inline QtTestRendererControl *rendererControl() { return service->rendererControl; }
-
- QtTestMediaService *service;
- QByteArray requestedService;
-};
-
-
-void tst_QmlGraphicsVideo::initTestCase()
-{
- qRegisterMetaType<QmlGraphicsVideo::Error>();
-}
-
-void tst_QmlGraphicsVideo::nullPlayerControl()
-{
- QtTestMediaServiceProvider provider(0, 0, 0);
-
- QmlGraphicsVideo video;
-
- QCOMPARE(video.source(), QUrl());
- video.setSource(QUrl("http://example.com"));
- QCOMPARE(video.source(), QUrl());
-
- QCOMPARE(video.isPlaying(), false);
- video.setPlaying(true);
- QCOMPARE(video.isPlaying(), false);
- video.play();
- QCOMPARE(video.isPlaying(), false);
-
- QCOMPARE(video.isPaused(), false);
- video.pause();
- QCOMPARE(video.isPaused(), false);
- video.setPaused(true);
- QCOMPARE(video.isPaused(), true);
-
- QCOMPARE(video.duration(), 0);
-
- QCOMPARE(video.position(), 0);
- video.setPosition(10000);
- QCOMPARE(video.position(), 0);
-
- QCOMPARE(video.volume(), qreal(0));
- video.setVolume(50);
- QCOMPARE(video.volume(), qreal(0));
-
- QCOMPARE(video.isMuted(), false);
- video.setMuted(true);
- QCOMPARE(video.isMuted(), false);
-
- QCOMPARE(video.bufferProgress(), qreal(0));
-
- QCOMPARE(video.isSeekable(), false);
-
- QCOMPARE(video.playbackRate(), qreal(1.0));
-
- QCOMPARE(video.hasAudio(), false);
- QCOMPARE(video.hasVideo(), false);
-
- QCOMPARE(video.status(), QmlGraphicsVideo::NoMedia);
-
- QCOMPARE(video.error(), QmlGraphicsVideo::ServiceMissing);
-}
-
-void tst_QmlGraphicsVideo::nullService()
-{
- QtTestMediaServiceProvider provider(0);
-
- QmlGraphicsVideo video;
-
- QCOMPARE(video.source(), QUrl());
- video.setSource(QUrl("http://example.com"));
- QCOMPARE(video.source(), QUrl());
-
- QCOMPARE(video.isPlaying(), false);
- video.setPlaying(true);
- QCOMPARE(video.isPlaying(), false);
- video.play();
- QCOMPARE(video.isPlaying(), false);
-
- QCOMPARE(video.isPaused(), false);
- video.pause();
- QCOMPARE(video.isPaused(), false);
- video.setPaused(true);
- QCOMPARE(video.isPaused(), true);
-
- QCOMPARE(video.duration(), 0);
-
- QCOMPARE(video.position(), 0);
- video.setPosition(10000);
- QCOMPARE(video.position(), 0);
-
- QCOMPARE(video.volume(), qreal(0));
- video.setVolume(50);
- QCOMPARE(video.volume(), qreal(0));
-
- QCOMPARE(video.isMuted(), false);
- video.setMuted(true);
- QCOMPARE(video.isMuted(), false);
-
- QCOMPARE(video.bufferProgress(), qreal(0));
-
- QCOMPARE(video.isSeekable(), false);
-
- QCOMPARE(video.playbackRate(), qreal(1.0));
-
- QCOMPARE(video.hasAudio(), false);
- QCOMPARE(video.hasVideo(), false);
-
- QCOMPARE(video.status(), QmlGraphicsVideo::NoMedia);
-
- QCOMPARE(video.error(), QmlGraphicsVideo::ServiceMissing);
-
- QCOMPARE(video.metaObject()->indexOfProperty("title"), -1);
- QCOMPARE(video.metaObject()->indexOfProperty("genre"), -1);
- QCOMPARE(video.metaObject()->indexOfProperty("description"), -1);
-}
-
-void tst_QmlGraphicsVideo::playing()
-{
- QtTestMediaServiceProvider provider;
- QmlGraphicsVideo video;
-
- QSignalSpy playingChangedSpy(&video, SIGNAL(playingChanged()));
- QSignalSpy startedSpy(&video, SIGNAL(started()));
- QSignalSpy stoppedSpy(&video, SIGNAL(stopped()));
-
- int playingChanged = 0;
- int started = 0;
- int stopped = 0;
-
- QCOMPARE(video.isPlaying(), false);
-
- // setPlaying(true) when stopped.
- video.setPlaying(true);
- QCOMPARE(video.isPlaying(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
- QCOMPARE(playingChangedSpy.count(), ++playingChanged);
- QCOMPARE(startedSpy.count(), ++started);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // setPlaying(false) when playing.
- video.setPlaying(false);
- QCOMPARE(video.isPlaying(), false);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
- QCOMPARE(playingChangedSpy.count(), ++playingChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(stoppedSpy.count(), ++stopped);
-
- // play() when stopped.
- video.play();
- QCOMPARE(video.isPlaying(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
- QCOMPARE(playingChangedSpy.count(), ++playingChanged);
- QCOMPARE(startedSpy.count(), ++started);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // stop() when playing.
- video.stop();
- QCOMPARE(video.isPlaying(), false);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
- QCOMPARE(playingChangedSpy.count(), ++playingChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(stoppedSpy.count(), ++stopped);
-
- // stop() when stopped.
- video.stop();
- QCOMPARE(video.isPlaying(), false);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // setPlaying(false) when stopped.
- video.setPlaying(false);
- QCOMPARE(video.isPlaying(), false);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- video.setPlaying(true);
- QCOMPARE(video.isPlaying(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
- QCOMPARE(playingChangedSpy.count(), ++playingChanged);
- QCOMPARE(startedSpy.count(), ++started);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // setPlaying(true) when playing.
- video.setPlaying(true);
- QCOMPARE(video.isPlaying(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // play() when playing.
- video.play();
- QCOMPARE(video.isPlaying(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(stoppedSpy.count(), stopped);
-}
-
-void tst_QmlGraphicsVideo::paused()
-{
- QtTestMediaServiceProvider provider;
- QmlGraphicsVideo video;
-
- QSignalSpy playingChangedSpy(&video, SIGNAL(playingChanged()));
- QSignalSpy pausedChangedSpy(&video, SIGNAL(pausedChanged()));
- QSignalSpy startedSpy(&video, SIGNAL(started()));
- QSignalSpy pausedSpy(&video, SIGNAL(paused()));
- QSignalSpy resumedSpy(&video, SIGNAL(resumed()));
- QSignalSpy stoppedSpy(&video, SIGNAL(stopped()));
-
- int playingChanged = 0;
- int pausedChanged = 0;
- int started = 0;
- int paused = 0;
- int resumed = 0;
- int stopped = 0;
-
- QCOMPARE(video.isPlaying(), false);
- QCOMPARE(video.isPaused(), false);
-
- // setPlaying(true) when stopped.
- video.setPlaying(true);
- QCOMPARE(video.isPlaying(), true);
- QCOMPARE(video.isPaused(), false);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
- QCOMPARE(playingChangedSpy.count(), ++playingChanged);
- QCOMPARE(pausedChangedSpy.count(), pausedChanged);
- QCOMPARE(startedSpy.count(), ++started);
- QCOMPARE(pausedSpy.count(), paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // setPaused(true) when playing.
- video.setPaused(true);
- QCOMPARE(video.isPlaying(), true);
- QCOMPARE(video.isPaused(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), ++paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // setPaused(true) when paused.
- video.setPaused(true);
- QCOMPARE(video.isPlaying(), true);
- QCOMPARE(video.isPaused(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(pausedChangedSpy.count(), pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // pause() when paused.
- video.pause();
- QCOMPARE(video.isPlaying(), true);
- QCOMPARE(video.isPaused(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(pausedChangedSpy.count(), pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // setPaused(false) when paused.
- video.setPaused(false);
- QCOMPARE(video.isPlaying(), true);
- QCOMPARE(video.isPaused(), false);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), paused);
- QCOMPARE(resumedSpy.count(), ++resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // setPaused(false) when playing.
- video.setPaused(false);
- QCOMPARE(video.isPlaying(), true);
- QCOMPARE(video.isPaused(), false);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(pausedChangedSpy.count(), pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // pause() when playing.
- video.pause();
- QCOMPARE(video.isPlaying(), true);
- QCOMPARE(video.isPaused(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), ++paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // setPlaying(false) when paused.
- video.setPlaying(false);
- QCOMPARE(video.isPlaying(), false);
- QCOMPARE(video.isPaused(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
- QCOMPARE(playingChangedSpy.count(), ++playingChanged);
- QCOMPARE(pausedChangedSpy.count(), pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), ++stopped);
-
- // setPaused(true) when stopped and paused.
- video.setPaused(true);
- QCOMPARE(video.isPlaying(), false);
- QCOMPARE(video.isPaused(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(pausedChangedSpy.count(), pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // setPaused(false) when stopped and paused.
- video.setPaused(false);
- QCOMPARE(video.isPlaying(), false);
- QCOMPARE(video.isPaused(), false);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // setPaused(true) when stopped.
- video.setPaused(true);
- QCOMPARE(video.isPlaying(), false);
- QCOMPARE(video.isPaused(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // setPlaying(true) when stopped and paused.
- video.setPlaying(true);
- QCOMPARE(video.isPlaying(), true);
- QCOMPARE(video.isPaused(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState);
- QCOMPARE(playingChangedSpy.count(), ++playingChanged);
- QCOMPARE(pausedChangedSpy.count(), pausedChanged);
- QCOMPARE(startedSpy.count(), ++started);
- QCOMPARE(pausedSpy.count(), ++paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // play() when paused.
- video.play();
- QCOMPARE(video.isPlaying(), true);
- QCOMPARE(video.isPaused(), false);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), paused);
- QCOMPARE(resumedSpy.count(), ++resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // setPaused(true) when playing.
- video.setPaused(true);
- QCOMPARE(video.isPlaying(), true);
- QCOMPARE(video.isPaused(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), ++paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // stop() when paused.
- video.stop();
- QCOMPARE(video.isPlaying(), false);
- QCOMPARE(video.isPaused(), false);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
- QCOMPARE(playingChangedSpy.count(), ++playingChanged);
- QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), ++stopped);
-
- // setPaused(true) when stopped.
- video.setPaused(true);
- QCOMPARE(video.isPlaying(), false);
- QCOMPARE(video.isPaused(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // stop() when stopped and paused.
- video.stop();
- QCOMPARE(video.isPlaying(), false);
- QCOMPARE(video.isPaused(), false);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // pause() when stopped.
- video.pause();
- QCOMPARE(video.isPlaying(), true);
- QCOMPARE(video.isPaused(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState);
- QCOMPARE(playingChangedSpy.count(), ++playingChanged);
- QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
- QCOMPARE(startedSpy.count(), ++started);
- QCOMPARE(pausedSpy.count(), ++paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // setPlaying(false) when paused.
- video.setPlaying(false);
- QCOMPARE(video.isPlaying(), false);
- QCOMPARE(video.isPaused(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
- QCOMPARE(playingChangedSpy.count(), ++playingChanged);
- QCOMPARE(pausedChangedSpy.count(), pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), ++stopped);
-
- // pause() when stopped and paused.
- video.pause();
- QCOMPARE(video.isPlaying(), true);
- QCOMPARE(video.isPaused(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState);
- QCOMPARE(playingChangedSpy.count(), ++playingChanged);
- QCOMPARE(pausedChangedSpy.count(), pausedChanged);
- QCOMPARE(startedSpy.count(), ++started);
- QCOMPARE(pausedSpy.count(), ++paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // setPlaying(false) when paused.
- video.setPlaying(false);
- QCOMPARE(video.isPlaying(), false);
- QCOMPARE(video.isPaused(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
- QCOMPARE(playingChangedSpy.count(), ++playingChanged);
- QCOMPARE(pausedChangedSpy.count(), pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), ++stopped);
-
- // play() when stopped and paused.
- video.play();
- QCOMPARE(video.isPlaying(), true);
- QCOMPARE(video.isPaused(), false);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
- QCOMPARE(playingChangedSpy.count(), ++playingChanged);
- QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
- QCOMPARE(startedSpy.count(), ++started);
- QCOMPARE(pausedSpy.count(), paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-}
-
-void tst_QmlGraphicsVideo::error()
-{
- const QString errorString = QLatin1String("Failed to open device.");
-
- QtTestMediaServiceProvider provider;
- QmlGraphicsVideo video;
-
- QSignalSpy errorSpy(&video, SIGNAL(error(QmlGraphicsVideo::Error,QString)));
- QSignalSpy errorChangedSpy(&video, SIGNAL(errorChanged()));
-
- QCOMPARE(video.error(), QmlGraphicsVideo::NoError);
- QCOMPARE(video.errorString(), QString());
-
- provider.playerControl()->emitError(QMediaPlayer::ResourceError, errorString);
-
- QCOMPARE(video.error(), QmlGraphicsVideo::ResourceError);
- QCOMPARE(video.errorString(), errorString);
- QCOMPARE(errorSpy.count(), 1);
- QCOMPARE(errorChangedSpy.count(), 1);
-
- // Changing the source resets the error properties.
- video.setSource(QUrl("http://example.com"));
- QCOMPARE(video.error(), QmlGraphicsVideo::NoError);
- QCOMPARE(video.errorString(), QString());
- QCOMPARE(errorSpy.count(), 1);
- QCOMPARE(errorChangedSpy.count(), 2);
-
- // But isn't noisy.
- video.setSource(QUrl("file:///file/path"));
- QCOMPARE(video.error(), QmlGraphicsVideo::NoError);
- QCOMPARE(video.errorString(), QString());
- QCOMPARE(errorSpy.count(), 1);
- QCOMPARE(errorChangedSpy.count(), 2);
-}
-
-
-void tst_QmlGraphicsVideo::hasAudio()
-{
- QtTestMediaServiceProvider provider;
- QmlGraphicsVideo video;
-
- QSignalSpy spy(&video, SIGNAL(hasAudioChanged()));
-
- QCOMPARE(video.hasAudio(), false);
-
- provider.playerControl()->setAudioAvailable(true);
- QCOMPARE(video.hasAudio(), true);
- QCOMPARE(spy.count(), 1);
-
- provider.playerControl()->setAudioAvailable(true);
- QCOMPARE(video.hasAudio(), true);
- QCOMPARE(spy.count(), 2);
-
- provider.playerControl()->setAudioAvailable(false);
- QCOMPARE(video.hasAudio(), false);
- QCOMPARE(spy.count(), 3);
-}
-
-void tst_QmlGraphicsVideo::hasVideo()
-{
- QtTestMediaServiceProvider provider;
- QmlGraphicsVideo video;
-
- QSignalSpy spy(&video, SIGNAL(hasVideoChanged()));
-
- QCOMPARE(video.hasVideo(), false);
-
- provider.playerControl()->setVideoAvailable(true);
- QCOMPARE(video.hasVideo(), true);
- QCOMPARE(spy.count(), 1);
-
- provider.playerControl()->setVideoAvailable(true);
- QCOMPARE(video.hasVideo(), true);
- QCOMPARE(spy.count(), 2);
-
- provider.playerControl()->setVideoAvailable(false);
- QCOMPARE(video.hasVideo(), false);
- QCOMPARE(spy.count(), 3);
-}
-
-void tst_QmlGraphicsVideo::fillMode()
-{
- QtTestMediaServiceProvider provider;
- QmlGraphicsVideo video;
-
- QList<QGraphicsItem *> children = video.childItems();
- QCOMPARE(children.count(), 1);
- QGraphicsVideoItem *videoItem = qgraphicsitem_cast<QGraphicsVideoItem *>(children.first());
- QVERIFY(videoItem != 0);
-
- QCOMPARE(video.fillMode(), QmlGraphicsVideo::PreserveAspectFit);
-
- video.setFillMode(QmlGraphicsVideo::PreserveAspectCrop);
- QCOMPARE(video.fillMode(), QmlGraphicsVideo::PreserveAspectCrop);
- QCOMPARE(videoItem->aspectRatioMode(), Qt::KeepAspectRatioByExpanding);
-
- video.setFillMode(QmlGraphicsVideo::Stretch);
- QCOMPARE(video.fillMode(), QmlGraphicsVideo::Stretch);
- QCOMPARE(videoItem->aspectRatioMode(), Qt::IgnoreAspectRatio);
-
- video.setFillMode(QmlGraphicsVideo::PreserveAspectFit);
- QCOMPARE(video.fillMode(), QmlGraphicsVideo::PreserveAspectFit);
- QCOMPARE(videoItem->aspectRatioMode(), Qt::KeepAspectRatio);
-}
-
-void tst_QmlGraphicsVideo::geometry()
-{
- QtTestMediaServiceProvider provider;
- QmlGraphicsVideo video;
-
- QAbstractVideoSurface *surface = provider.rendererControl()->surface();
- QVERIFY(surface != 0);
-
- QList<QGraphicsItem *> children = video.childItems();
- QCOMPARE(children.count(), 1);
- QGraphicsVideoItem *videoItem = qgraphicsitem_cast<QGraphicsVideoItem *>(children.first());
- QVERIFY(videoItem != 0);
-
- QVideoSurfaceFormat format(QSize(640, 480), QVideoFrame::Format_RGB32);
-
- QVERIFY(surface->start(format));
-
- QCOMPARE(video.implicitWidth(), qreal(640));
- QCOMPARE(video.implicitHeight(), qreal(480));
-
- video.setWidth(560);
- video.setHeight(328);
-
- QCOMPARE(videoItem->size().width(), qreal(560));
- QCOMPARE(videoItem->size().height(), qreal(328));
-}
-
-QTEST_MAIN(tst_QmlGraphicsVideo)
-
-#include "tst_qmlgraphicsvideo.moc"