From fe9e91d5b9a5504fdc00f53abd5972621e7fa7dd Mon Sep 17 00:00:00 2001 From: Leonardo Sobral Cunha Date: Thu, 11 Feb 2010 21:35:45 +0000 Subject: Adds qml prefix to all declarative autotests --- tests/auto/declarative/anchors/anchors.pro | 6 - tests/auto/declarative/anchors/data/anchors.qml | 162 --- tests/auto/declarative/anchors/data/centerin.qml | 12 - tests/auto/declarative/anchors/data/crash1.qml | 11 - tests/auto/declarative/anchors/data/fill.qml | 14 - tests/auto/declarative/anchors/data/loop1.qml | 8 - tests/auto/declarative/anchors/data/loop2.qml | 20 - tests/auto/declarative/anchors/data/margins.qml | 13 - tests/auto/declarative/anchors/tst_anchors.cpp | 459 ------- .../declarative/animatedimage/animatedimage.pro | 7 - .../auto/declarative/animatedimage/data/colors.gif | Bin 505 -> 0 bytes .../auto/declarative/animatedimage/data/colors.qml | 5 - .../declarative/animatedimage/data/stickman.gif | Bin 164923 -> 0 bytes .../declarative/animatedimage/data/stickman.qml | 5 - .../animatedimage/data/stickmanpause.qml | 7 - .../animatedimage/data/stickmanstopped.qml | 6 - .../animatedimage/tst_animatedimage.cpp | 191 --- tests/auto/declarative/animations/animations.pro | 6 - .../auto/declarative/animations/data/attached.qml | 34 - .../declarative/animations/data/badproperty1.qml | 21 - .../declarative/animations/data/badproperty2.qml | 21 - .../auto/declarative/animations/data/badtype1.qml | 12 - .../auto/declarative/animations/data/badtype2.qml | 12 - .../auto/declarative/animations/data/badtype3.qml | 12 - .../auto/declarative/animations/data/badtype4.qml | 27 - .../declarative/animations/data/dotproperty.qml | 24 - .../declarative/animations/data/mixedtype1.qml | 25 - .../declarative/animations/data/mixedtype2.qml | 25 - .../declarative/animations/data/properties.qml | 14 - .../declarative/animations/data/properties2.qml | 14 - .../declarative/animations/data/properties3.qml | 14 - .../declarative/animations/data/properties4.qml | 14 - .../declarative/animations/data/properties5.qml | 14 - .../animations/data/propertiesTransition.qml | 29 - .../animations/data/propertiesTransition2.qml | 29 - .../animations/data/propertiesTransition3.qml | 29 - .../animations/data/propertiesTransition4.qml | 29 - .../animations/data/propertiesTransition5.qml | 29 - .../animations/data/propertiesTransition6.qml | 29 - .../declarative/animations/data/valuesource.qml | 14 - .../declarative/animations/data/valuesource2.qml | 14 - .../auto/declarative/animations/tst_animations.cpp | 611 --------- tests/auto/declarative/behaviors/behaviors.pro | 6 - tests/auto/declarative/behaviors/data/binding.qml | 26 - tests/auto/declarative/behaviors/data/color.qml | 24 - .../auto/declarative/behaviors/data/cpptrigger.qml | 11 - tests/auto/declarative/behaviors/data/disabled.qml | 27 - tests/auto/declarative/behaviors/data/empty.qml | 23 - .../declarative/behaviors/data/groupProperty.qml | 23 - .../declarative/behaviors/data/groupProperty2.qml | 23 - tests/auto/declarative/behaviors/data/loop.qml | 19 - .../declarative/behaviors/data/nonSelecting.qml | 26 - .../declarative/behaviors/data/nonSelecting2.qml | 26 - tests/auto/declarative/behaviors/data/parent.qml | 28 - .../behaviors/data/reassignedAnimation.qml | 27 - .../declarative/behaviors/data/scripttrigger.qml | 16 - tests/auto/declarative/behaviors/data/simple.qml | 26 - tests/auto/declarative/behaviors/tst_behaviors.cpp | 281 ----- .../datetimeformatter/datetimeformatter.pro | 5 - .../datetimeformatter/tst_datetimeformatter.cpp | 150 --- tests/auto/declarative/declarative.pro | 20 +- .../numberformatter/numberformatter.pro | 5 - .../numberformatter/tst_numberformatter.cpp | 222 ---- .../declarative/qmlanimations/data/attached.qml | 34 + .../qmlanimations/data/badproperty1.qml | 21 + .../qmlanimations/data/badproperty2.qml | 21 + .../declarative/qmlanimations/data/badtype1.qml | 12 + .../declarative/qmlanimations/data/badtype2.qml | 12 + .../declarative/qmlanimations/data/badtype3.qml | 12 + .../declarative/qmlanimations/data/badtype4.qml | 27 + .../declarative/qmlanimations/data/dotproperty.qml | 24 + .../declarative/qmlanimations/data/mixedtype1.qml | 25 + .../declarative/qmlanimations/data/mixedtype2.qml | 25 + .../declarative/qmlanimations/data/properties.qml | 14 + .../declarative/qmlanimations/data/properties2.qml | 14 + .../declarative/qmlanimations/data/properties3.qml | 14 + .../declarative/qmlanimations/data/properties4.qml | 14 + .../declarative/qmlanimations/data/properties5.qml | 14 + .../qmlanimations/data/propertiesTransition.qml | 29 + .../qmlanimations/data/propertiesTransition2.qml | 29 + .../qmlanimations/data/propertiesTransition3.qml | 29 + .../qmlanimations/data/propertiesTransition4.qml | 29 + .../qmlanimations/data/propertiesTransition5.qml | 29 + .../qmlanimations/data/propertiesTransition6.qml | 29 + .../declarative/qmlanimations/data/valuesource.qml | 14 + .../qmlanimations/data/valuesource2.qml | 14 + .../declarative/qmlanimations/qmlanimations.pro | 6 + .../qmlanimations/tst_qmlanimations.cpp | 611 +++++++++ .../auto/declarative/qmlbehaviors/data/binding.qml | 26 + tests/auto/declarative/qmlbehaviors/data/color.qml | 24 + .../declarative/qmlbehaviors/data/cpptrigger.qml | 11 + .../declarative/qmlbehaviors/data/disabled.qml | 27 + tests/auto/declarative/qmlbehaviors/data/empty.qml | 23 + .../qmlbehaviors/data/groupProperty.qml | 23 + .../qmlbehaviors/data/groupProperty2.qml | 23 + tests/auto/declarative/qmlbehaviors/data/loop.qml | 19 + .../declarative/qmlbehaviors/data/nonSelecting.qml | 26 + .../qmlbehaviors/data/nonSelecting2.qml | 26 + .../auto/declarative/qmlbehaviors/data/parent.qml | 28 + .../qmlbehaviors/data/reassignedAnimation.qml | 27 + .../qmlbehaviors/data/scripttrigger.qml | 16 + .../auto/declarative/qmlbehaviors/data/simple.qml | 26 + .../auto/declarative/qmlbehaviors/qmlbehaviors.pro | 6 + .../declarative/qmlbehaviors/tst_qmlbehaviors.cpp | 281 +++++ .../qmldatetimeformatter/qmldatetimeformatter.pro | 5 + .../tst_qmldatetimeformatter.cpp | 150 +++ .../qmlgraphicsanchors/data/anchors.qml | 162 +++ .../qmlgraphicsanchors/data/centerin.qml | 12 + .../declarative/qmlgraphicsanchors/data/crash1.qml | 11 + .../declarative/qmlgraphicsanchors/data/fill.qml | 14 + .../declarative/qmlgraphicsanchors/data/loop1.qml | 8 + .../declarative/qmlgraphicsanchors/data/loop2.qml | 20 + .../qmlgraphicsanchors/data/margins.qml | 13 + .../qmlgraphicsanchors/qmlgraphicsanchors.pro | 6 + .../qmlgraphicsanchors/tst_qmlgraphicsanchors.cpp | 459 +++++++ .../qmlgraphicsanimatedimage/data/colors.gif | Bin 0 -> 505 bytes .../qmlgraphicsanimatedimage/data/colors.qml | 5 + .../qmlgraphicsanimatedimage/data/stickman.gif | Bin 0 -> 164923 bytes .../qmlgraphicsanimatedimage/data/stickman.qml | 5 + .../data/stickmanpause.qml | 7 + .../data/stickmanstopped.qml | 6 + .../qmlgraphicsanimatedimage.pro | 7 + .../tst_qmlgraphicsanimatedimage.cpp | 191 +++ .../qmlnumberformatter/qmlnumberformatter.pro | 5 + .../qmlnumberformatter/tst_qmlnumberformatter.cpp | 222 ++++ .../qmlstates/data/ExtendedRectangle.qml | 19 + .../declarative/qmlstates/data/anchorChanges.qml | 23 + .../declarative/qmlstates/data/anchorChanges2.qml | 21 + .../declarative/qmlstates/data/anchorChanges3.qml | 29 + .../declarative/qmlstates/data/anchorChanges4.qml | 22 + .../declarative/qmlstates/data/anchorChanges5.qml | 22 + .../data/autoStateAtStartupRestoreBug.qml | 18 + .../declarative/qmlstates/data/basicBinding.qml | 12 + .../declarative/qmlstates/data/basicBinding2.qml | 12 + .../declarative/qmlstates/data/basicBinding3.qml | 13 + .../declarative/qmlstates/data/basicBinding4.qml | 17 + .../declarative/qmlstates/data/basicChanges.qml | 10 + .../declarative/qmlstates/data/basicChanges2.qml | 15 + .../declarative/qmlstates/data/basicChanges3.qml | 15 + .../declarative/qmlstates/data/basicExtension.qml | 16 + tests/auto/declarative/qmlstates/data/deleting.qml | 11 + .../declarative/qmlstates/data/deletingState.qml | 13 + tests/auto/declarative/qmlstates/data/explicit.qml | 15 + .../declarative/qmlstates/data/fakeExtension.qml | 16 + .../qmlstates/data/illegalTempState.qml | 21 + .../declarative/qmlstates/data/legalTempState.qml | 23 + .../declarative/qmlstates/data/nonExistantProp.qml | 11 + .../declarative/qmlstates/data/parentChange.qml | 37 + .../declarative/qmlstates/data/parentChange2.qml | 31 + .../declarative/qmlstates/data/parentChange3.qml | 42 + .../declarative/qmlstates/data/parentChange4.qml | 30 + .../declarative/qmlstates/data/parentChange5.qml | 30 + .../declarative/qmlstates/data/propertyErrors.qml | 10 + .../qmlstates/data/restoreEntryValues.qml | 14 + tests/auto/declarative/qmlstates/data/script.qml | 10 + .../declarative/qmlstates/data/signalOverride.qml | 18 + .../declarative/qmlstates/data/signalOverride2.qml | 9 + .../qmlstates/data/signalOverrideCrash.qml | 15 + tests/auto/declarative/qmlstates/qmlstates.pro | 8 + tests/auto/declarative/qmlstates/tst_qmlstates.cpp | 887 +++++++++++++ .../qmlvaluetypes/data/autoBindingRemoval.2.qml | 9 + .../qmlvaluetypes/data/autoBindingRemoval.3.qml | 10 + .../qmlvaluetypes/data/autoBindingRemoval.qml | 9 + .../qmlvaluetypes/data/bindingAssignment.qml | 7 + .../qmlvaluetypes/data/bindingConflict.qml | 8 + .../declarative/qmlvaluetypes/data/bindingRead.qml | 5 + .../qmlvaluetypes/data/bindingVariantCopy.qml | 13 + .../qmlvaluetypes/data/deletedObject.js | 13 + .../qmlvaluetypes/data/deletedObject.qml | 12 + .../declarative/qmlvaluetypes/data/font_read.qml | 18 + .../qmlvaluetypes/data/font_write.2.qml | 6 + .../qmlvaluetypes/data/font_write.3.qml | 7 + .../declarative/qmlvaluetypes/data/font_write.qml | 16 + .../declarative/qmlvaluetypes/data/point_read.qml | 7 + .../declarative/qmlvaluetypes/data/point_write.qml | 6 + .../declarative/qmlvaluetypes/data/pointf_read.qml | 8 + .../qmlvaluetypes/data/pointf_write.qml | 6 + .../declarative/qmlvaluetypes/data/rect_read.qml | 10 + .../declarative/qmlvaluetypes/data/rect_write.qml | 9 + .../declarative/qmlvaluetypes/data/rectf_read.qml | 10 + .../declarative/qmlvaluetypes/data/rectf_write.qml | 9 + .../qmlvaluetypes/data/scriptAccess.qml | 9 + .../qmlvaluetypes/data/scriptVariantCopy.qml | 14 + .../declarative/qmlvaluetypes/data/size_read.qml | 8 + .../declarative/qmlvaluetypes/data/size_write.qml | 7 + .../declarative/qmlvaluetypes/data/sizef_read.qml | 9 + .../declarative/qmlvaluetypes/data/sizef_write.qml | 6 + .../qmlvaluetypes/data/staticAssignment.qml | 5 + .../qmlvaluetypes/data/valueInterceptors.qml | 8 + .../qmlvaluetypes/data/valueSources.qml | 5 + .../qmlvaluetypes/data/vector3d_read.qml | 9 + .../qmlvaluetypes/data/vector3d_write.qml | 8 + .../declarative/qmlvaluetypes/qmlvaluetypes.pro | 10 + tests/auto/declarative/qmlvaluetypes/testtypes.cpp | 45 + tests/auto/declarative/qmlvaluetypes/testtypes.h | 152 +++ .../qmlvaluetypes/tst_qmlvaluetypes.cpp | 588 +++++++++ .../qmlxmlhttprequest/data/abort.expect | 10 + .../declarative/qmlxmlhttprequest/data/abort.qml | 42 + .../declarative/qmlxmlhttprequest/data/abort.reply | 2 + .../qmlxmlhttprequest/data/abort_opened.qml | 58 + .../qmlxmlhttprequest/data/abort_unsent.qml | 54 + .../declarative/qmlxmlhttprequest/data/attr.qml | 80 ++ .../declarative/qmlxmlhttprequest/data/attr.xml | 1 + .../qmlxmlhttprequest/data/callbackException.qml | 25 + .../declarative/qmlxmlhttprequest/data/cdata.qml | 135 ++ .../declarative/qmlxmlhttprequest/data/cdata.xml | 2 + .../qmlxmlhttprequest/data/constructor.qml | 14 + .../qmlxmlhttprequest/data/defaultState.qml | 30 + .../qmlxmlhttprequest/data/document.qml | 58 + .../qmlxmlhttprequest/data/document.xml | 3 + .../qmlxmlhttprequest/data/domExceptionCodes.qml | 60 + .../declarative/qmlxmlhttprequest/data/element.qml | 147 +++ .../declarative/qmlxmlhttprequest/data/element.xml | 1 + .../data/getAllResponseHeaders.qml | 65 + .../data/getAllResponseHeaders_args.qml | 23 + .../data/getAllResponseHeaders_sent.qml | 20 + .../data/getAllResponseHeaders_unsent.qml | 16 + .../data/getResponseHeader.expect | 7 + .../qmlxmlhttprequest/data/getResponseHeader.qml | 75 ++ .../qmlxmlhttprequest/data/getResponseHeader.reply | 7 + .../data/getResponseHeader_args.qml | 23 + .../data/getResponseHeader_sent.qml | 20 + .../data/getResponseHeader_unsent.qml | 16 + .../qmlxmlhttprequest/data/instanceStateValues.qml | 33 + .../qmlxmlhttprequest/data/invalidMethodUsage.qml | 160 +++ .../declarative/qmlxmlhttprequest/data/open.qml | 53 + .../qmlxmlhttprequest/data/open_arg_count.1.qml | 18 + .../qmlxmlhttprequest/data/open_arg_count.2.qml | 18 + .../qmlxmlhttprequest/data/open_invalid_method.qml | 16 + .../qmlxmlhttprequest/data/open_network.expect | 7 + .../qmlxmlhttprequest/data/open_network.reply | 2 + .../qmlxmlhttprequest/data/open_network.wait | 0 .../qmlxmlhttprequest/data/open_sync.qml | 17 + .../qmlxmlhttprequest/data/open_user.qml | 53 + .../qmlxmlhttprequest/data/open_username.qml | 54 + .../qmlxmlhttprequest/data/redirectError.qml | 23 + .../qmlxmlhttprequest/data/redirectRecur.qml | 23 + .../qmlxmlhttprequest/data/redirects.qml | 22 + .../qmlxmlhttprequest/data/redirecttarget.html | 1 + .../qmlxmlhttprequest/data/responseText.qml | 52 + .../qmlxmlhttprequest/data/responseXML_invalid.qml | 24 + .../qmlxmlhttprequest/data/seconddocument.html | 1 + .../qmlxmlhttprequest/data/send_alreadySent.qml | 27 + .../qmlxmlhttprequest/data/send_data.1.expect | 10 + .../qmlxmlhttprequest/data/send_data.1.qml | 21 + .../qmlxmlhttprequest/data/send_data.2.qml | 23 + .../qmlxmlhttprequest/data/send_data.3.qml | 23 + .../qmlxmlhttprequest/data/send_data.4.expect | 10 + .../qmlxmlhttprequest/data/send_data.4.qml | 23 + .../qmlxmlhttprequest/data/send_data.5.qml | 23 + .../qmlxmlhttprequest/data/send_data.6.expect | 10 + .../qmlxmlhttprequest/data/send_data.6.qml | 21 + .../qmlxmlhttprequest/data/send_data.7.qml | 23 + .../qmlxmlhttprequest/data/send_data.reply | 2 + .../qmlxmlhttprequest/data/send_ignoreData.qml | 26 + .../qmlxmlhttprequest/data/send_ignoreData.reply | 2 + .../data/send_ignoreData_GET.expect | 7 + .../data/send_ignoreData_PUT.expect | 7 + .../qmlxmlhttprequest/data/send_unsent.qml | 16 + .../qmlxmlhttprequest/data/setRequestHeader.expect | 9 + .../qmlxmlhttprequest/data/setRequestHeader.qml | 28 + .../qmlxmlhttprequest/data/setRequestHeader.reply | 2 + .../data/setRequestHeader_args.qml | 18 + .../data/setRequestHeader_illegalName.qml | 57 + .../data/setRequestHeader_sent.qml | 31 + .../data/setRequestHeader_unsent.qml | 17 + .../qmlxmlhttprequest/data/staticStateValues.qml | 24 + .../qmlxmlhttprequest/data/status.200.reply | 2 + .../qmlxmlhttprequest/data/status.404.reply | 2 + .../qmlxmlhttprequest/data/status.expect | 7 + .../declarative/qmlxmlhttprequest/data/status.qml | 77 ++ .../qmlxmlhttprequest/data/statusText.qml | 77 ++ .../qmlxmlhttprequest/data/testdocument.html | 1 + .../declarative/qmlxmlhttprequest/data/text.qml | 131 ++ .../declarative/qmlxmlhttprequest/data/text.xml | 1 + .../qmlxmlhttprequest/qmlxmlhttprequest.pro | 13 + .../qmlxmlhttprequest/tst_qmlxmlhttprequest.cpp | 1315 ++++++++++++++++++++ .../declarative/states/data/ExtendedRectangle.qml | 19 - .../auto/declarative/states/data/anchorChanges.qml | 23 - .../declarative/states/data/anchorChanges2.qml | 21 - .../declarative/states/data/anchorChanges3.qml | 29 - .../declarative/states/data/anchorChanges4.qml | 22 - .../declarative/states/data/anchorChanges5.qml | 22 - .../states/data/autoStateAtStartupRestoreBug.qml | 18 - .../auto/declarative/states/data/basicBinding.qml | 12 - .../auto/declarative/states/data/basicBinding2.qml | 12 - .../auto/declarative/states/data/basicBinding3.qml | 13 - .../auto/declarative/states/data/basicBinding4.qml | 17 - .../auto/declarative/states/data/basicChanges.qml | 10 - .../auto/declarative/states/data/basicChanges2.qml | 15 - .../auto/declarative/states/data/basicChanges3.qml | 15 - .../declarative/states/data/basicExtension.qml | 16 - tests/auto/declarative/states/data/deleting.qml | 11 - .../auto/declarative/states/data/deletingState.qml | 13 - tests/auto/declarative/states/data/explicit.qml | 15 - .../auto/declarative/states/data/fakeExtension.qml | 16 - .../declarative/states/data/illegalTempState.qml | 21 - .../declarative/states/data/legalTempState.qml | 23 - .../declarative/states/data/nonExistantProp.qml | 11 - .../auto/declarative/states/data/parentChange.qml | 37 - .../auto/declarative/states/data/parentChange2.qml | 31 - .../auto/declarative/states/data/parentChange3.qml | 42 - .../auto/declarative/states/data/parentChange4.qml | 30 - .../auto/declarative/states/data/parentChange5.qml | 30 - .../declarative/states/data/propertyErrors.qml | 10 - .../declarative/states/data/restoreEntryValues.qml | 14 - tests/auto/declarative/states/data/script.qml | 10 - .../declarative/states/data/signalOverride.qml | 18 - .../declarative/states/data/signalOverride2.qml | 9 - .../states/data/signalOverrideCrash.qml | 15 - tests/auto/declarative/states/states.pro | 8 - tests/auto/declarative/states/tst_states.cpp | 887 ------------- .../valuetypes/data/autoBindingRemoval.2.qml | 9 - .../valuetypes/data/autoBindingRemoval.3.qml | 10 - .../valuetypes/data/autoBindingRemoval.qml | 9 - .../valuetypes/data/bindingAssignment.qml | 7 - .../valuetypes/data/bindingConflict.qml | 8 - .../declarative/valuetypes/data/bindingRead.qml | 5 - .../valuetypes/data/bindingVariantCopy.qml | 13 - .../declarative/valuetypes/data/deletedObject.js | 13 - .../declarative/valuetypes/data/deletedObject.qml | 12 - .../auto/declarative/valuetypes/data/font_read.qml | 18 - .../declarative/valuetypes/data/font_write.2.qml | 6 - .../declarative/valuetypes/data/font_write.3.qml | 7 - .../declarative/valuetypes/data/font_write.qml | 16 - .../declarative/valuetypes/data/point_read.qml | 7 - .../declarative/valuetypes/data/point_write.qml | 6 - .../declarative/valuetypes/data/pointf_read.qml | 8 - .../declarative/valuetypes/data/pointf_write.qml | 6 - .../auto/declarative/valuetypes/data/rect_read.qml | 10 - .../declarative/valuetypes/data/rect_write.qml | 9 - .../declarative/valuetypes/data/rectf_read.qml | 10 - .../declarative/valuetypes/data/rectf_write.qml | 9 - .../declarative/valuetypes/data/scriptAccess.qml | 9 - .../valuetypes/data/scriptVariantCopy.qml | 14 - .../auto/declarative/valuetypes/data/size_read.qml | 8 - .../declarative/valuetypes/data/size_write.qml | 7 - .../declarative/valuetypes/data/sizef_read.qml | 9 - .../declarative/valuetypes/data/sizef_write.qml | 6 - .../valuetypes/data/staticAssignment.qml | 5 - .../valuetypes/data/valueInterceptors.qml | 8 - .../declarative/valuetypes/data/valueSources.qml | 5 - .../declarative/valuetypes/data/vector3d_read.qml | 9 - .../declarative/valuetypes/data/vector3d_write.qml | 8 - tests/auto/declarative/valuetypes/testtypes.cpp | 45 - tests/auto/declarative/valuetypes/testtypes.h | 152 --- .../auto/declarative/valuetypes/tst_valuetypes.cpp | 588 --------- tests/auto/declarative/valuetypes/valuetypes.pro | 10 - .../declarative/xmlhttprequest/data/abort.expect | 10 - .../auto/declarative/xmlhttprequest/data/abort.qml | 42 - .../declarative/xmlhttprequest/data/abort.reply | 2 - .../xmlhttprequest/data/abort_opened.qml | 58 - .../xmlhttprequest/data/abort_unsent.qml | 54 - .../auto/declarative/xmlhttprequest/data/attr.qml | 80 -- .../auto/declarative/xmlhttprequest/data/attr.xml | 1 - .../xmlhttprequest/data/callbackException.qml | 25 - .../auto/declarative/xmlhttprequest/data/cdata.qml | 135 -- .../auto/declarative/xmlhttprequest/data/cdata.xml | 2 - .../xmlhttprequest/data/constructor.qml | 14 - .../xmlhttprequest/data/defaultState.qml | 30 - .../declarative/xmlhttprequest/data/document.qml | 58 - .../declarative/xmlhttprequest/data/document.xml | 3 - .../xmlhttprequest/data/domExceptionCodes.qml | 60 - .../declarative/xmlhttprequest/data/element.qml | 147 --- .../declarative/xmlhttprequest/data/element.xml | 1 - .../xmlhttprequest/data/getAllResponseHeaders.qml | 65 - .../data/getAllResponseHeaders_args.qml | 23 - .../data/getAllResponseHeaders_sent.qml | 20 - .../data/getAllResponseHeaders_unsent.qml | 16 - .../xmlhttprequest/data/getResponseHeader.expect | 7 - .../xmlhttprequest/data/getResponseHeader.qml | 75 -- .../xmlhttprequest/data/getResponseHeader.reply | 7 - .../xmlhttprequest/data/getResponseHeader_args.qml | 23 - .../xmlhttprequest/data/getResponseHeader_sent.qml | 20 - .../data/getResponseHeader_unsent.qml | 16 - .../xmlhttprequest/data/instanceStateValues.qml | 33 - .../xmlhttprequest/data/invalidMethodUsage.qml | 160 --- .../auto/declarative/xmlhttprequest/data/open.qml | 53 - .../xmlhttprequest/data/open_arg_count.1.qml | 18 - .../xmlhttprequest/data/open_arg_count.2.qml | 18 - .../xmlhttprequest/data/open_invalid_method.qml | 16 - .../xmlhttprequest/data/open_network.expect | 7 - .../xmlhttprequest/data/open_network.reply | 2 - .../xmlhttprequest/data/open_network.wait | 0 .../declarative/xmlhttprequest/data/open_sync.qml | 17 - .../declarative/xmlhttprequest/data/open_user.qml | 53 - .../xmlhttprequest/data/open_username.qml | 54 - .../xmlhttprequest/data/redirectError.qml | 23 - .../xmlhttprequest/data/redirectRecur.qml | 23 - .../declarative/xmlhttprequest/data/redirects.qml | 22 - .../xmlhttprequest/data/redirecttarget.html | 1 - .../xmlhttprequest/data/responseText.qml | 52 - .../xmlhttprequest/data/responseXML_invalid.qml | 24 - .../xmlhttprequest/data/seconddocument.html | 1 - .../xmlhttprequest/data/send_alreadySent.qml | 27 - .../xmlhttprequest/data/send_data.1.expect | 10 - .../xmlhttprequest/data/send_data.1.qml | 21 - .../xmlhttprequest/data/send_data.2.qml | 23 - .../xmlhttprequest/data/send_data.3.qml | 23 - .../xmlhttprequest/data/send_data.4.expect | 10 - .../xmlhttprequest/data/send_data.4.qml | 23 - .../xmlhttprequest/data/send_data.5.qml | 23 - .../xmlhttprequest/data/send_data.6.expect | 10 - .../xmlhttprequest/data/send_data.6.qml | 21 - .../xmlhttprequest/data/send_data.7.qml | 23 - .../xmlhttprequest/data/send_data.reply | 2 - .../xmlhttprequest/data/send_ignoreData.qml | 26 - .../xmlhttprequest/data/send_ignoreData.reply | 2 - .../xmlhttprequest/data/send_ignoreData_GET.expect | 7 - .../xmlhttprequest/data/send_ignoreData_PUT.expect | 7 - .../xmlhttprequest/data/send_unsent.qml | 16 - .../xmlhttprequest/data/setRequestHeader.expect | 9 - .../xmlhttprequest/data/setRequestHeader.qml | 28 - .../xmlhttprequest/data/setRequestHeader.reply | 2 - .../xmlhttprequest/data/setRequestHeader_args.qml | 18 - .../data/setRequestHeader_illegalName.qml | 57 - .../xmlhttprequest/data/setRequestHeader_sent.qml | 31 - .../data/setRequestHeader_unsent.qml | 17 - .../xmlhttprequest/data/staticStateValues.qml | 24 - .../xmlhttprequest/data/status.200.reply | 2 - .../xmlhttprequest/data/status.404.reply | 2 - .../declarative/xmlhttprequest/data/status.expect | 7 - .../declarative/xmlhttprequest/data/status.qml | 77 -- .../declarative/xmlhttprequest/data/statusText.qml | 77 -- .../xmlhttprequest/data/testdocument.html | 1 - .../auto/declarative/xmlhttprequest/data/text.qml | 131 -- .../auto/declarative/xmlhttprequest/data/text.xml | 1 - .../xmlhttprequest/tst_xmlhttprequest.cpp | 1315 -------------------- .../declarative/xmlhttprequest/xmlhttprequest.pro | 13 - 429 files changed, 9285 insertions(+), 9285 deletions(-) delete mode 100644 tests/auto/declarative/anchors/anchors.pro delete mode 100644 tests/auto/declarative/anchors/data/anchors.qml delete mode 100644 tests/auto/declarative/anchors/data/centerin.qml delete mode 100644 tests/auto/declarative/anchors/data/crash1.qml delete mode 100644 tests/auto/declarative/anchors/data/fill.qml delete mode 100644 tests/auto/declarative/anchors/data/loop1.qml delete mode 100644 tests/auto/declarative/anchors/data/loop2.qml delete mode 100644 tests/auto/declarative/anchors/data/margins.qml delete mode 100644 tests/auto/declarative/anchors/tst_anchors.cpp delete mode 100644 tests/auto/declarative/animatedimage/animatedimage.pro delete mode 100644 tests/auto/declarative/animatedimage/data/colors.gif delete mode 100644 tests/auto/declarative/animatedimage/data/colors.qml delete mode 100644 tests/auto/declarative/animatedimage/data/stickman.gif delete mode 100644 tests/auto/declarative/animatedimage/data/stickman.qml delete mode 100644 tests/auto/declarative/animatedimage/data/stickmanpause.qml delete mode 100644 tests/auto/declarative/animatedimage/data/stickmanstopped.qml delete mode 100644 tests/auto/declarative/animatedimage/tst_animatedimage.cpp delete mode 100644 tests/auto/declarative/animations/animations.pro delete mode 100644 tests/auto/declarative/animations/data/attached.qml delete mode 100644 tests/auto/declarative/animations/data/badproperty1.qml delete mode 100644 tests/auto/declarative/animations/data/badproperty2.qml delete mode 100644 tests/auto/declarative/animations/data/badtype1.qml delete mode 100644 tests/auto/declarative/animations/data/badtype2.qml delete mode 100644 tests/auto/declarative/animations/data/badtype3.qml delete mode 100644 tests/auto/declarative/animations/data/badtype4.qml delete mode 100644 tests/auto/declarative/animations/data/dotproperty.qml delete mode 100644 tests/auto/declarative/animations/data/mixedtype1.qml delete mode 100644 tests/auto/declarative/animations/data/mixedtype2.qml delete mode 100644 tests/auto/declarative/animations/data/properties.qml delete mode 100644 tests/auto/declarative/animations/data/properties2.qml delete mode 100644 tests/auto/declarative/animations/data/properties3.qml delete mode 100644 tests/auto/declarative/animations/data/properties4.qml delete mode 100644 tests/auto/declarative/animations/data/properties5.qml delete mode 100644 tests/auto/declarative/animations/data/propertiesTransition.qml delete mode 100644 tests/auto/declarative/animations/data/propertiesTransition2.qml delete mode 100644 tests/auto/declarative/animations/data/propertiesTransition3.qml delete mode 100644 tests/auto/declarative/animations/data/propertiesTransition4.qml delete mode 100644 tests/auto/declarative/animations/data/propertiesTransition5.qml delete mode 100644 tests/auto/declarative/animations/data/propertiesTransition6.qml delete mode 100644 tests/auto/declarative/animations/data/valuesource.qml delete mode 100644 tests/auto/declarative/animations/data/valuesource2.qml delete mode 100644 tests/auto/declarative/animations/tst_animations.cpp delete mode 100644 tests/auto/declarative/behaviors/behaviors.pro delete mode 100644 tests/auto/declarative/behaviors/data/binding.qml delete mode 100644 tests/auto/declarative/behaviors/data/color.qml delete mode 100644 tests/auto/declarative/behaviors/data/cpptrigger.qml delete mode 100644 tests/auto/declarative/behaviors/data/disabled.qml delete mode 100644 tests/auto/declarative/behaviors/data/empty.qml delete mode 100644 tests/auto/declarative/behaviors/data/groupProperty.qml delete mode 100644 tests/auto/declarative/behaviors/data/groupProperty2.qml delete mode 100644 tests/auto/declarative/behaviors/data/loop.qml delete mode 100644 tests/auto/declarative/behaviors/data/nonSelecting.qml delete mode 100644 tests/auto/declarative/behaviors/data/nonSelecting2.qml delete mode 100644 tests/auto/declarative/behaviors/data/parent.qml delete mode 100644 tests/auto/declarative/behaviors/data/reassignedAnimation.qml delete mode 100644 tests/auto/declarative/behaviors/data/scripttrigger.qml delete mode 100644 tests/auto/declarative/behaviors/data/simple.qml delete mode 100644 tests/auto/declarative/behaviors/tst_behaviors.cpp delete mode 100644 tests/auto/declarative/datetimeformatter/datetimeformatter.pro delete mode 100644 tests/auto/declarative/datetimeformatter/tst_datetimeformatter.cpp delete mode 100644 tests/auto/declarative/numberformatter/numberformatter.pro delete mode 100644 tests/auto/declarative/numberformatter/tst_numberformatter.cpp create mode 100644 tests/auto/declarative/qmlanimations/data/attached.qml create mode 100644 tests/auto/declarative/qmlanimations/data/badproperty1.qml create mode 100644 tests/auto/declarative/qmlanimations/data/badproperty2.qml create mode 100644 tests/auto/declarative/qmlanimations/data/badtype1.qml create mode 100644 tests/auto/declarative/qmlanimations/data/badtype2.qml create mode 100644 tests/auto/declarative/qmlanimations/data/badtype3.qml create mode 100644 tests/auto/declarative/qmlanimations/data/badtype4.qml create mode 100644 tests/auto/declarative/qmlanimations/data/dotproperty.qml create mode 100644 tests/auto/declarative/qmlanimations/data/mixedtype1.qml create mode 100644 tests/auto/declarative/qmlanimations/data/mixedtype2.qml create mode 100644 tests/auto/declarative/qmlanimations/data/properties.qml create mode 100644 tests/auto/declarative/qmlanimations/data/properties2.qml create mode 100644 tests/auto/declarative/qmlanimations/data/properties3.qml create mode 100644 tests/auto/declarative/qmlanimations/data/properties4.qml create mode 100644 tests/auto/declarative/qmlanimations/data/properties5.qml create mode 100644 tests/auto/declarative/qmlanimations/data/propertiesTransition.qml create mode 100644 tests/auto/declarative/qmlanimations/data/propertiesTransition2.qml create mode 100644 tests/auto/declarative/qmlanimations/data/propertiesTransition3.qml create mode 100644 tests/auto/declarative/qmlanimations/data/propertiesTransition4.qml create mode 100644 tests/auto/declarative/qmlanimations/data/propertiesTransition5.qml create mode 100644 tests/auto/declarative/qmlanimations/data/propertiesTransition6.qml create mode 100644 tests/auto/declarative/qmlanimations/data/valuesource.qml create mode 100644 tests/auto/declarative/qmlanimations/data/valuesource2.qml create mode 100644 tests/auto/declarative/qmlanimations/qmlanimations.pro create mode 100644 tests/auto/declarative/qmlanimations/tst_qmlanimations.cpp create mode 100644 tests/auto/declarative/qmlbehaviors/data/binding.qml create mode 100644 tests/auto/declarative/qmlbehaviors/data/color.qml create mode 100644 tests/auto/declarative/qmlbehaviors/data/cpptrigger.qml create mode 100644 tests/auto/declarative/qmlbehaviors/data/disabled.qml create mode 100644 tests/auto/declarative/qmlbehaviors/data/empty.qml create mode 100644 tests/auto/declarative/qmlbehaviors/data/groupProperty.qml create mode 100644 tests/auto/declarative/qmlbehaviors/data/groupProperty2.qml create mode 100644 tests/auto/declarative/qmlbehaviors/data/loop.qml create mode 100644 tests/auto/declarative/qmlbehaviors/data/nonSelecting.qml create mode 100644 tests/auto/declarative/qmlbehaviors/data/nonSelecting2.qml create mode 100644 tests/auto/declarative/qmlbehaviors/data/parent.qml create mode 100644 tests/auto/declarative/qmlbehaviors/data/reassignedAnimation.qml create mode 100644 tests/auto/declarative/qmlbehaviors/data/scripttrigger.qml create mode 100644 tests/auto/declarative/qmlbehaviors/data/simple.qml create mode 100644 tests/auto/declarative/qmlbehaviors/qmlbehaviors.pro create mode 100644 tests/auto/declarative/qmlbehaviors/tst_qmlbehaviors.cpp create mode 100644 tests/auto/declarative/qmldatetimeformatter/qmldatetimeformatter.pro create mode 100644 tests/auto/declarative/qmldatetimeformatter/tst_qmldatetimeformatter.cpp create mode 100644 tests/auto/declarative/qmlgraphicsanchors/data/anchors.qml create mode 100644 tests/auto/declarative/qmlgraphicsanchors/data/centerin.qml create mode 100644 tests/auto/declarative/qmlgraphicsanchors/data/crash1.qml create mode 100644 tests/auto/declarative/qmlgraphicsanchors/data/fill.qml create mode 100644 tests/auto/declarative/qmlgraphicsanchors/data/loop1.qml create mode 100644 tests/auto/declarative/qmlgraphicsanchors/data/loop2.qml create mode 100644 tests/auto/declarative/qmlgraphicsanchors/data/margins.qml create mode 100644 tests/auto/declarative/qmlgraphicsanchors/qmlgraphicsanchors.pro create mode 100644 tests/auto/declarative/qmlgraphicsanchors/tst_qmlgraphicsanchors.cpp create mode 100644 tests/auto/declarative/qmlgraphicsanimatedimage/data/colors.gif create mode 100644 tests/auto/declarative/qmlgraphicsanimatedimage/data/colors.qml create mode 100644 tests/auto/declarative/qmlgraphicsanimatedimage/data/stickman.gif create mode 100644 tests/auto/declarative/qmlgraphicsanimatedimage/data/stickman.qml create mode 100644 tests/auto/declarative/qmlgraphicsanimatedimage/data/stickmanpause.qml create mode 100644 tests/auto/declarative/qmlgraphicsanimatedimage/data/stickmanstopped.qml create mode 100644 tests/auto/declarative/qmlgraphicsanimatedimage/qmlgraphicsanimatedimage.pro create mode 100644 tests/auto/declarative/qmlgraphicsanimatedimage/tst_qmlgraphicsanimatedimage.cpp create mode 100644 tests/auto/declarative/qmlnumberformatter/qmlnumberformatter.pro create mode 100644 tests/auto/declarative/qmlnumberformatter/tst_qmlnumberformatter.cpp create mode 100644 tests/auto/declarative/qmlstates/data/ExtendedRectangle.qml create mode 100644 tests/auto/declarative/qmlstates/data/anchorChanges.qml create mode 100644 tests/auto/declarative/qmlstates/data/anchorChanges2.qml create mode 100644 tests/auto/declarative/qmlstates/data/anchorChanges3.qml create mode 100644 tests/auto/declarative/qmlstates/data/anchorChanges4.qml create mode 100644 tests/auto/declarative/qmlstates/data/anchorChanges5.qml create mode 100644 tests/auto/declarative/qmlstates/data/autoStateAtStartupRestoreBug.qml create mode 100644 tests/auto/declarative/qmlstates/data/basicBinding.qml create mode 100644 tests/auto/declarative/qmlstates/data/basicBinding2.qml create mode 100644 tests/auto/declarative/qmlstates/data/basicBinding3.qml create mode 100644 tests/auto/declarative/qmlstates/data/basicBinding4.qml create mode 100644 tests/auto/declarative/qmlstates/data/basicChanges.qml create mode 100644 tests/auto/declarative/qmlstates/data/basicChanges2.qml create mode 100644 tests/auto/declarative/qmlstates/data/basicChanges3.qml create mode 100644 tests/auto/declarative/qmlstates/data/basicExtension.qml create mode 100644 tests/auto/declarative/qmlstates/data/deleting.qml create mode 100644 tests/auto/declarative/qmlstates/data/deletingState.qml create mode 100644 tests/auto/declarative/qmlstates/data/explicit.qml create mode 100644 tests/auto/declarative/qmlstates/data/fakeExtension.qml create mode 100644 tests/auto/declarative/qmlstates/data/illegalTempState.qml create mode 100644 tests/auto/declarative/qmlstates/data/legalTempState.qml create mode 100644 tests/auto/declarative/qmlstates/data/nonExistantProp.qml create mode 100644 tests/auto/declarative/qmlstates/data/parentChange.qml create mode 100644 tests/auto/declarative/qmlstates/data/parentChange2.qml create mode 100644 tests/auto/declarative/qmlstates/data/parentChange3.qml create mode 100644 tests/auto/declarative/qmlstates/data/parentChange4.qml create mode 100644 tests/auto/declarative/qmlstates/data/parentChange5.qml create mode 100644 tests/auto/declarative/qmlstates/data/propertyErrors.qml create mode 100644 tests/auto/declarative/qmlstates/data/restoreEntryValues.qml create mode 100644 tests/auto/declarative/qmlstates/data/script.qml create mode 100644 tests/auto/declarative/qmlstates/data/signalOverride.qml create mode 100644 tests/auto/declarative/qmlstates/data/signalOverride2.qml create mode 100644 tests/auto/declarative/qmlstates/data/signalOverrideCrash.qml create mode 100644 tests/auto/declarative/qmlstates/qmlstates.pro create mode 100644 tests/auto/declarative/qmlstates/tst_qmlstates.cpp create mode 100644 tests/auto/declarative/qmlvaluetypes/data/autoBindingRemoval.2.qml create mode 100644 tests/auto/declarative/qmlvaluetypes/data/autoBindingRemoval.3.qml create mode 100644 tests/auto/declarative/qmlvaluetypes/data/autoBindingRemoval.qml create mode 100644 tests/auto/declarative/qmlvaluetypes/data/bindingAssignment.qml create mode 100644 tests/auto/declarative/qmlvaluetypes/data/bindingConflict.qml create mode 100644 tests/auto/declarative/qmlvaluetypes/data/bindingRead.qml create mode 100644 tests/auto/declarative/qmlvaluetypes/data/bindingVariantCopy.qml create mode 100644 tests/auto/declarative/qmlvaluetypes/data/deletedObject.js create mode 100644 tests/auto/declarative/qmlvaluetypes/data/deletedObject.qml create mode 100644 tests/auto/declarative/qmlvaluetypes/data/font_read.qml create mode 100644 tests/auto/declarative/qmlvaluetypes/data/font_write.2.qml create mode 100644 tests/auto/declarative/qmlvaluetypes/data/font_write.3.qml create mode 100644 tests/auto/declarative/qmlvaluetypes/data/font_write.qml create mode 100644 tests/auto/declarative/qmlvaluetypes/data/point_read.qml create mode 100644 tests/auto/declarative/qmlvaluetypes/data/point_write.qml create mode 100644 tests/auto/declarative/qmlvaluetypes/data/pointf_read.qml create mode 100644 tests/auto/declarative/qmlvaluetypes/data/pointf_write.qml create mode 100644 tests/auto/declarative/qmlvaluetypes/data/rect_read.qml create mode 100644 tests/auto/declarative/qmlvaluetypes/data/rect_write.qml create mode 100644 tests/auto/declarative/qmlvaluetypes/data/rectf_read.qml create mode 100644 tests/auto/declarative/qmlvaluetypes/data/rectf_write.qml create mode 100644 tests/auto/declarative/qmlvaluetypes/data/scriptAccess.qml create mode 100644 tests/auto/declarative/qmlvaluetypes/data/scriptVariantCopy.qml create mode 100644 tests/auto/declarative/qmlvaluetypes/data/size_read.qml create mode 100644 tests/auto/declarative/qmlvaluetypes/data/size_write.qml create mode 100644 tests/auto/declarative/qmlvaluetypes/data/sizef_read.qml create mode 100644 tests/auto/declarative/qmlvaluetypes/data/sizef_write.qml create mode 100644 tests/auto/declarative/qmlvaluetypes/data/staticAssignment.qml create mode 100644 tests/auto/declarative/qmlvaluetypes/data/valueInterceptors.qml create mode 100644 tests/auto/declarative/qmlvaluetypes/data/valueSources.qml create mode 100644 tests/auto/declarative/qmlvaluetypes/data/vector3d_read.qml create mode 100644 tests/auto/declarative/qmlvaluetypes/data/vector3d_write.qml create mode 100644 tests/auto/declarative/qmlvaluetypes/qmlvaluetypes.pro create mode 100644 tests/auto/declarative/qmlvaluetypes/testtypes.cpp create mode 100644 tests/auto/declarative/qmlvaluetypes/testtypes.h create mode 100644 tests/auto/declarative/qmlvaluetypes/tst_qmlvaluetypes.cpp create mode 100644 tests/auto/declarative/qmlxmlhttprequest/data/abort.expect create mode 100644 tests/auto/declarative/qmlxmlhttprequest/data/abort.qml create mode 100644 tests/auto/declarative/qmlxmlhttprequest/data/abort.reply create mode 100644 tests/auto/declarative/qmlxmlhttprequest/data/abort_opened.qml create mode 100644 tests/auto/declarative/qmlxmlhttprequest/data/abort_unsent.qml create mode 100644 tests/auto/declarative/qmlxmlhttprequest/data/attr.qml create mode 100644 tests/auto/declarative/qmlxmlhttprequest/data/attr.xml create mode 100644 tests/auto/declarative/qmlxmlhttprequest/data/callbackException.qml create mode 100644 tests/auto/declarative/qmlxmlhttprequest/data/cdata.qml create mode 100644 tests/auto/declarative/qmlxmlhttprequest/data/cdata.xml create mode 100644 tests/auto/declarative/qmlxmlhttprequest/data/constructor.qml create mode 100644 tests/auto/declarative/qmlxmlhttprequest/data/defaultState.qml create mode 100644 tests/auto/declarative/qmlxmlhttprequest/data/document.qml create mode 100644 tests/auto/declarative/qmlxmlhttprequest/data/document.xml create mode 100644 tests/auto/declarative/qmlxmlhttprequest/data/domExceptionCodes.qml create mode 100644 tests/auto/declarative/qmlxmlhttprequest/data/element.qml create mode 100644 tests/auto/declarative/qmlxmlhttprequest/data/element.xml create mode 100644 tests/auto/declarative/qmlxmlhttprequest/data/getAllResponseHeaders.qml create mode 100644 tests/auto/declarative/qmlxmlhttprequest/data/getAllResponseHeaders_args.qml create mode 100644 tests/auto/declarative/qmlxmlhttprequest/data/getAllResponseHeaders_sent.qml create mode 100644 tests/auto/declarative/qmlxmlhttprequest/data/getAllResponseHeaders_unsent.qml create mode 100644 tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader.expect create mode 100644 tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader.qml create mode 100644 tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader.reply create mode 100644 tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader_args.qml create mode 100644 tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader_sent.qml create mode 100644 tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader_unsent.qml create mode 100644 tests/auto/declarative/qmlxmlhttprequest/data/instanceStateValues.qml create mode 100644 tests/auto/declarative/qmlxmlhttprequest/data/invalidMethodUsage.qml create mode 100644 tests/auto/declarative/qmlxmlhttprequest/data/open.qml create mode 100644 tests/auto/declarative/qmlxmlhttprequest/data/open_arg_count.1.qml create mode 100644 tests/auto/declarative/qmlxmlhttprequest/data/open_arg_count.2.qml create mode 100644 tests/auto/declarative/qmlxmlhttprequest/data/open_invalid_method.qml create mode 100644 tests/auto/declarative/qmlxmlhttprequest/data/open_network.expect create mode 100644 tests/auto/declarative/qmlxmlhttprequest/data/open_network.reply create mode 100644 tests/auto/declarative/qmlxmlhttprequest/data/open_network.wait create mode 100644 tests/auto/declarative/qmlxmlhttprequest/data/open_sync.qml create mode 100644 tests/auto/declarative/qmlxmlhttprequest/data/open_user.qml create mode 100644 tests/auto/declarative/qmlxmlhttprequest/data/open_username.qml create mode 100644 tests/auto/declarative/qmlxmlhttprequest/data/redirectError.qml create mode 100644 tests/auto/declarative/qmlxmlhttprequest/data/redirectRecur.qml create mode 100644 tests/auto/declarative/qmlxmlhttprequest/data/redirects.qml create mode 100644 tests/auto/declarative/qmlxmlhttprequest/data/redirecttarget.html create mode 100644 tests/auto/declarative/qmlxmlhttprequest/data/responseText.qml create mode 100644 tests/auto/declarative/qmlxmlhttprequest/data/responseXML_invalid.qml create mode 100644 tests/auto/declarative/qmlxmlhttprequest/data/seconddocument.html create mode 100644 tests/auto/declarative/qmlxmlhttprequest/data/send_alreadySent.qml create mode 100644 tests/auto/declarative/qmlxmlhttprequest/data/send_data.1.expect create mode 100644 tests/auto/declarative/qmlxmlhttprequest/data/send_data.1.qml create mode 100644 tests/auto/declarative/qmlxmlhttprequest/data/send_data.2.qml create mode 100644 tests/auto/declarative/qmlxmlhttprequest/data/send_data.3.qml create mode 100644 tests/auto/declarative/qmlxmlhttprequest/data/send_data.4.expect create mode 100644 tests/auto/declarative/qmlxmlhttprequest/data/send_data.4.qml create mode 100644 tests/auto/declarative/qmlxmlhttprequest/data/send_data.5.qml create mode 100644 tests/auto/declarative/qmlxmlhttprequest/data/send_data.6.expect create mode 100644 tests/auto/declarative/qmlxmlhttprequest/data/send_data.6.qml create mode 100644 tests/auto/declarative/qmlxmlhttprequest/data/send_data.7.qml create mode 100644 tests/auto/declarative/qmlxmlhttprequest/data/send_data.reply create mode 100644 tests/auto/declarative/qmlxmlhttprequest/data/send_ignoreData.qml create mode 100644 tests/auto/declarative/qmlxmlhttprequest/data/send_ignoreData.reply create mode 100644 tests/auto/declarative/qmlxmlhttprequest/data/send_ignoreData_GET.expect create mode 100644 tests/auto/declarative/qmlxmlhttprequest/data/send_ignoreData_PUT.expect create mode 100644 tests/auto/declarative/qmlxmlhttprequest/data/send_unsent.qml create mode 100644 tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader.expect create mode 100644 tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader.qml create mode 100644 tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader.reply create mode 100644 tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader_args.qml create mode 100644 tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader_illegalName.qml create mode 100644 tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader_sent.qml create mode 100644 tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader_unsent.qml create mode 100644 tests/auto/declarative/qmlxmlhttprequest/data/staticStateValues.qml create mode 100644 tests/auto/declarative/qmlxmlhttprequest/data/status.200.reply create mode 100644 tests/auto/declarative/qmlxmlhttprequest/data/status.404.reply create mode 100644 tests/auto/declarative/qmlxmlhttprequest/data/status.expect create mode 100644 tests/auto/declarative/qmlxmlhttprequest/data/status.qml create mode 100644 tests/auto/declarative/qmlxmlhttprequest/data/statusText.qml create mode 100644 tests/auto/declarative/qmlxmlhttprequest/data/testdocument.html create mode 100644 tests/auto/declarative/qmlxmlhttprequest/data/text.qml create mode 100644 tests/auto/declarative/qmlxmlhttprequest/data/text.xml create mode 100644 tests/auto/declarative/qmlxmlhttprequest/qmlxmlhttprequest.pro create mode 100644 tests/auto/declarative/qmlxmlhttprequest/tst_qmlxmlhttprequest.cpp delete mode 100644 tests/auto/declarative/states/data/ExtendedRectangle.qml delete mode 100644 tests/auto/declarative/states/data/anchorChanges.qml delete mode 100644 tests/auto/declarative/states/data/anchorChanges2.qml delete mode 100644 tests/auto/declarative/states/data/anchorChanges3.qml delete mode 100644 tests/auto/declarative/states/data/anchorChanges4.qml delete mode 100644 tests/auto/declarative/states/data/anchorChanges5.qml delete mode 100644 tests/auto/declarative/states/data/autoStateAtStartupRestoreBug.qml delete mode 100644 tests/auto/declarative/states/data/basicBinding.qml delete mode 100644 tests/auto/declarative/states/data/basicBinding2.qml delete mode 100644 tests/auto/declarative/states/data/basicBinding3.qml delete mode 100644 tests/auto/declarative/states/data/basicBinding4.qml delete mode 100644 tests/auto/declarative/states/data/basicChanges.qml delete mode 100644 tests/auto/declarative/states/data/basicChanges2.qml delete mode 100644 tests/auto/declarative/states/data/basicChanges3.qml delete mode 100644 tests/auto/declarative/states/data/basicExtension.qml delete mode 100644 tests/auto/declarative/states/data/deleting.qml delete mode 100644 tests/auto/declarative/states/data/deletingState.qml delete mode 100644 tests/auto/declarative/states/data/explicit.qml delete mode 100644 tests/auto/declarative/states/data/fakeExtension.qml delete mode 100644 tests/auto/declarative/states/data/illegalTempState.qml delete mode 100644 tests/auto/declarative/states/data/legalTempState.qml delete mode 100644 tests/auto/declarative/states/data/nonExistantProp.qml delete mode 100644 tests/auto/declarative/states/data/parentChange.qml delete mode 100644 tests/auto/declarative/states/data/parentChange2.qml delete mode 100644 tests/auto/declarative/states/data/parentChange3.qml delete mode 100644 tests/auto/declarative/states/data/parentChange4.qml delete mode 100644 tests/auto/declarative/states/data/parentChange5.qml delete mode 100644 tests/auto/declarative/states/data/propertyErrors.qml delete mode 100644 tests/auto/declarative/states/data/restoreEntryValues.qml delete mode 100644 tests/auto/declarative/states/data/script.qml delete mode 100644 tests/auto/declarative/states/data/signalOverride.qml delete mode 100644 tests/auto/declarative/states/data/signalOverride2.qml delete mode 100644 tests/auto/declarative/states/data/signalOverrideCrash.qml delete mode 100644 tests/auto/declarative/states/states.pro delete mode 100644 tests/auto/declarative/states/tst_states.cpp delete mode 100644 tests/auto/declarative/valuetypes/data/autoBindingRemoval.2.qml delete mode 100644 tests/auto/declarative/valuetypes/data/autoBindingRemoval.3.qml delete mode 100644 tests/auto/declarative/valuetypes/data/autoBindingRemoval.qml delete mode 100644 tests/auto/declarative/valuetypes/data/bindingAssignment.qml delete mode 100644 tests/auto/declarative/valuetypes/data/bindingConflict.qml delete mode 100644 tests/auto/declarative/valuetypes/data/bindingRead.qml delete mode 100644 tests/auto/declarative/valuetypes/data/bindingVariantCopy.qml delete mode 100644 tests/auto/declarative/valuetypes/data/deletedObject.js delete mode 100644 tests/auto/declarative/valuetypes/data/deletedObject.qml delete mode 100644 tests/auto/declarative/valuetypes/data/font_read.qml delete mode 100644 tests/auto/declarative/valuetypes/data/font_write.2.qml delete mode 100644 tests/auto/declarative/valuetypes/data/font_write.3.qml delete mode 100644 tests/auto/declarative/valuetypes/data/font_write.qml delete mode 100644 tests/auto/declarative/valuetypes/data/point_read.qml delete mode 100644 tests/auto/declarative/valuetypes/data/point_write.qml delete mode 100644 tests/auto/declarative/valuetypes/data/pointf_read.qml delete mode 100644 tests/auto/declarative/valuetypes/data/pointf_write.qml delete mode 100644 tests/auto/declarative/valuetypes/data/rect_read.qml delete mode 100644 tests/auto/declarative/valuetypes/data/rect_write.qml delete mode 100644 tests/auto/declarative/valuetypes/data/rectf_read.qml delete mode 100644 tests/auto/declarative/valuetypes/data/rectf_write.qml delete mode 100644 tests/auto/declarative/valuetypes/data/scriptAccess.qml delete mode 100644 tests/auto/declarative/valuetypes/data/scriptVariantCopy.qml delete mode 100644 tests/auto/declarative/valuetypes/data/size_read.qml delete mode 100644 tests/auto/declarative/valuetypes/data/size_write.qml delete mode 100644 tests/auto/declarative/valuetypes/data/sizef_read.qml delete mode 100644 tests/auto/declarative/valuetypes/data/sizef_write.qml delete mode 100644 tests/auto/declarative/valuetypes/data/staticAssignment.qml delete mode 100644 tests/auto/declarative/valuetypes/data/valueInterceptors.qml delete mode 100644 tests/auto/declarative/valuetypes/data/valueSources.qml delete mode 100644 tests/auto/declarative/valuetypes/data/vector3d_read.qml delete mode 100644 tests/auto/declarative/valuetypes/data/vector3d_write.qml delete mode 100644 tests/auto/declarative/valuetypes/testtypes.cpp delete mode 100644 tests/auto/declarative/valuetypes/testtypes.h delete mode 100644 tests/auto/declarative/valuetypes/tst_valuetypes.cpp delete mode 100644 tests/auto/declarative/valuetypes/valuetypes.pro delete mode 100644 tests/auto/declarative/xmlhttprequest/data/abort.expect delete mode 100644 tests/auto/declarative/xmlhttprequest/data/abort.qml delete mode 100644 tests/auto/declarative/xmlhttprequest/data/abort.reply delete mode 100644 tests/auto/declarative/xmlhttprequest/data/abort_opened.qml delete mode 100644 tests/auto/declarative/xmlhttprequest/data/abort_unsent.qml delete mode 100644 tests/auto/declarative/xmlhttprequest/data/attr.qml delete mode 100644 tests/auto/declarative/xmlhttprequest/data/attr.xml delete mode 100644 tests/auto/declarative/xmlhttprequest/data/callbackException.qml delete mode 100644 tests/auto/declarative/xmlhttprequest/data/cdata.qml delete mode 100644 tests/auto/declarative/xmlhttprequest/data/cdata.xml delete mode 100644 tests/auto/declarative/xmlhttprequest/data/constructor.qml delete mode 100644 tests/auto/declarative/xmlhttprequest/data/defaultState.qml delete mode 100644 tests/auto/declarative/xmlhttprequest/data/document.qml delete mode 100644 tests/auto/declarative/xmlhttprequest/data/document.xml delete mode 100644 tests/auto/declarative/xmlhttprequest/data/domExceptionCodes.qml delete mode 100644 tests/auto/declarative/xmlhttprequest/data/element.qml delete mode 100644 tests/auto/declarative/xmlhttprequest/data/element.xml delete mode 100644 tests/auto/declarative/xmlhttprequest/data/getAllResponseHeaders.qml delete mode 100644 tests/auto/declarative/xmlhttprequest/data/getAllResponseHeaders_args.qml delete mode 100644 tests/auto/declarative/xmlhttprequest/data/getAllResponseHeaders_sent.qml delete mode 100644 tests/auto/declarative/xmlhttprequest/data/getAllResponseHeaders_unsent.qml delete mode 100644 tests/auto/declarative/xmlhttprequest/data/getResponseHeader.expect delete mode 100644 tests/auto/declarative/xmlhttprequest/data/getResponseHeader.qml delete mode 100644 tests/auto/declarative/xmlhttprequest/data/getResponseHeader.reply delete mode 100644 tests/auto/declarative/xmlhttprequest/data/getResponseHeader_args.qml delete mode 100644 tests/auto/declarative/xmlhttprequest/data/getResponseHeader_sent.qml delete mode 100644 tests/auto/declarative/xmlhttprequest/data/getResponseHeader_unsent.qml delete mode 100644 tests/auto/declarative/xmlhttprequest/data/instanceStateValues.qml delete mode 100644 tests/auto/declarative/xmlhttprequest/data/invalidMethodUsage.qml delete mode 100644 tests/auto/declarative/xmlhttprequest/data/open.qml delete mode 100644 tests/auto/declarative/xmlhttprequest/data/open_arg_count.1.qml delete mode 100644 tests/auto/declarative/xmlhttprequest/data/open_arg_count.2.qml delete mode 100644 tests/auto/declarative/xmlhttprequest/data/open_invalid_method.qml delete mode 100644 tests/auto/declarative/xmlhttprequest/data/open_network.expect delete mode 100644 tests/auto/declarative/xmlhttprequest/data/open_network.reply delete mode 100644 tests/auto/declarative/xmlhttprequest/data/open_network.wait delete mode 100644 tests/auto/declarative/xmlhttprequest/data/open_sync.qml delete mode 100644 tests/auto/declarative/xmlhttprequest/data/open_user.qml delete mode 100644 tests/auto/declarative/xmlhttprequest/data/open_username.qml delete mode 100644 tests/auto/declarative/xmlhttprequest/data/redirectError.qml delete mode 100644 tests/auto/declarative/xmlhttprequest/data/redirectRecur.qml delete mode 100644 tests/auto/declarative/xmlhttprequest/data/redirects.qml delete mode 100644 tests/auto/declarative/xmlhttprequest/data/redirecttarget.html delete mode 100644 tests/auto/declarative/xmlhttprequest/data/responseText.qml delete mode 100644 tests/auto/declarative/xmlhttprequest/data/responseXML_invalid.qml delete mode 100644 tests/auto/declarative/xmlhttprequest/data/seconddocument.html delete mode 100644 tests/auto/declarative/xmlhttprequest/data/send_alreadySent.qml delete mode 100644 tests/auto/declarative/xmlhttprequest/data/send_data.1.expect delete mode 100644 tests/auto/declarative/xmlhttprequest/data/send_data.1.qml delete mode 100644 tests/auto/declarative/xmlhttprequest/data/send_data.2.qml delete mode 100644 tests/auto/declarative/xmlhttprequest/data/send_data.3.qml delete mode 100644 tests/auto/declarative/xmlhttprequest/data/send_data.4.expect delete mode 100644 tests/auto/declarative/xmlhttprequest/data/send_data.4.qml delete mode 100644 tests/auto/declarative/xmlhttprequest/data/send_data.5.qml delete mode 100644 tests/auto/declarative/xmlhttprequest/data/send_data.6.expect delete mode 100644 tests/auto/declarative/xmlhttprequest/data/send_data.6.qml delete mode 100644 tests/auto/declarative/xmlhttprequest/data/send_data.7.qml delete mode 100644 tests/auto/declarative/xmlhttprequest/data/send_data.reply delete mode 100644 tests/auto/declarative/xmlhttprequest/data/send_ignoreData.qml delete mode 100644 tests/auto/declarative/xmlhttprequest/data/send_ignoreData.reply delete mode 100644 tests/auto/declarative/xmlhttprequest/data/send_ignoreData_GET.expect delete mode 100644 tests/auto/declarative/xmlhttprequest/data/send_ignoreData_PUT.expect delete mode 100644 tests/auto/declarative/xmlhttprequest/data/send_unsent.qml delete mode 100644 tests/auto/declarative/xmlhttprequest/data/setRequestHeader.expect delete mode 100644 tests/auto/declarative/xmlhttprequest/data/setRequestHeader.qml delete mode 100644 tests/auto/declarative/xmlhttprequest/data/setRequestHeader.reply delete mode 100644 tests/auto/declarative/xmlhttprequest/data/setRequestHeader_args.qml delete mode 100644 tests/auto/declarative/xmlhttprequest/data/setRequestHeader_illegalName.qml delete mode 100644 tests/auto/declarative/xmlhttprequest/data/setRequestHeader_sent.qml delete mode 100644 tests/auto/declarative/xmlhttprequest/data/setRequestHeader_unsent.qml delete mode 100644 tests/auto/declarative/xmlhttprequest/data/staticStateValues.qml delete mode 100644 tests/auto/declarative/xmlhttprequest/data/status.200.reply delete mode 100644 tests/auto/declarative/xmlhttprequest/data/status.404.reply delete mode 100644 tests/auto/declarative/xmlhttprequest/data/status.expect delete mode 100644 tests/auto/declarative/xmlhttprequest/data/status.qml delete mode 100644 tests/auto/declarative/xmlhttprequest/data/statusText.qml delete mode 100644 tests/auto/declarative/xmlhttprequest/data/testdocument.html delete mode 100644 tests/auto/declarative/xmlhttprequest/data/text.qml delete mode 100644 tests/auto/declarative/xmlhttprequest/data/text.xml delete mode 100644 tests/auto/declarative/xmlhttprequest/tst_xmlhttprequest.cpp delete mode 100644 tests/auto/declarative/xmlhttprequest/xmlhttprequest.pro diff --git a/tests/auto/declarative/anchors/anchors.pro b/tests/auto/declarative/anchors/anchors.pro deleted file mode 100644 index 1e25a90..0000000 --- a/tests/auto/declarative/anchors/anchors.pro +++ /dev/null @@ -1,6 +0,0 @@ -load(qttest_p4) -contains(QT_CONFIG,declarative): QT += declarative -SOURCES += tst_anchors.cpp -macx:CONFIG -= app_bundle - -DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/anchors/data/anchors.qml b/tests/auto/declarative/anchors/data/anchors.qml deleted file mode 100644 index b64d0b0..0000000 --- a/tests/auto/declarative/anchors/data/anchors.qml +++ /dev/null @@ -1,162 +0,0 @@ -import Qt 4.6 - -Rectangle { - color: "white" - width: 240 - height: 320 - Rectangle { id: masterRect; objectName: "masterRect"; x: 26; width: 96; height: 20; color: "red" } - Rectangle { - id: rect1; objectName: "rect1" - y: 20; width: 10; height: 10 - anchors.left: masterRect.left - } - Rectangle { - id: rect2; objectName: "rect2" - y: 20; width: 10; height: 10 - anchors.left: masterRect.right - } - Rectangle { - id: rect3; objectName: "rect3" - y: 20; width: 10; height: 10 - anchors.left: masterRect.horizontalCenter - } - Rectangle { - id: rect4; objectName: "rect4" - y: 30; width: 10; height: 10 - anchors.right: masterRect.left - } - Rectangle { - id: rect5; objectName: "rect5" - y: 30; width: 10; height: 10 - anchors.right: masterRect.right - } - Rectangle { - id: rect6; objectName: "rect6" - y: 30; width: 10; height: 10 - anchors.right: masterRect.horizontalCenter - } - Rectangle { - id: rect7; objectName: "rect7" - y: 50; width: 10; height: 10 - anchors.left: parent.left - } - Rectangle { - id: rect8; objectName: "rect8" - y: 50; width: 10; height: 10 - anchors.left: parent.right - } - Rectangle { - id: rect9; objectName: "rect9" - y: 50; width: 10; height: 10 - anchors.left: parent.horizontalCenter - } - Rectangle { - id: rect10; objectName: "rect10" - y: 60; width: 10; height: 10 - anchors.right: parent.left - } - Rectangle { - id: rect11; objectName: "rect11" - y: 60; width: 10; height: 10 - anchors.right: parent.right - } - Rectangle { - id: rect12; objectName: "rect12" - y: 60; width: 10; height: 10 - anchors.right: parent.horizontalCenter - } - Rectangle { - id: rect13; objectName: "rect13" - x: 200; width: 10; height: 10 - anchors.top: masterRect.bottom - } - Rectangle { - id: rect14; objectName: "rect14" - width: 10; height: 10; color: "steelblue" - anchors.verticalCenter: parent.verticalCenter - } - Rectangle { - id: rect15; objectName: "rect15" - y: 200; height: 10 - anchors.left: masterRect.left - anchors.right: masterRect.right - } - Rectangle { - id: rect16; objectName: "rect16" - y: 220; height: 10 - anchors.left: masterRect.left - anchors.horizontalCenter: masterRect.right - } - Rectangle { - id: rect17; objectName: "rect17" - y: 240; height: 10 - anchors.right: masterRect.right - anchors.horizontalCenter: masterRect.left - } - Rectangle { - id: rect18; objectName: "rect18" - x: 180; width: 10 - anchors.top: masterRect.bottom - anchors.bottom: rect12.top - } - Rectangle { - id: rect19; objectName: "rect19" - y: 70; width: 10; height: 10 - anchors.horizontalCenter: parent.horizontalCenter - } - Rectangle { - id: rect20; objectName: "rect20" - y: 70; width: 10; height: 10 - anchors.horizontalCenter: parent.right - } - Rectangle { - id: rect21; objectName: "rect21" - y: 70; width: 10; height: 10 - anchors.horizontalCenter: parent.left - } - Rectangle { - id: rect22; objectName: "rect22" - width: 10; height: 10 - anchors.centerIn: masterRect - } - Rectangle { - id: rect23; objectName: "rect23" - anchors.left: masterRect.left - anchors.leftMargin: 5 - anchors.right: masterRect.right - anchors.rightMargin: 5 - anchors.top: masterRect.top - anchors.topMargin: 5 - anchors.bottom: masterRect.bottom - anchors.bottomMargin: 5 - } - Rectangle { - id: rect24; objectName: "rect24" - width: 10; height: 10 - anchors.horizontalCenter: masterRect.left - anchors.horizontalCenterOffset: width/2 - } - Rectangle { - id: rect25; objectName: "rect25" - width: 10; height: 10 - anchors.verticalCenter: rect12.top - anchors.verticalCenterOffset: height/2 - } - Rectangle { - id: rect26; objectName: "rect26" - width: 10; height: 10 - anchors.baseline: masterRect.top - anchors.baselineOffset: height/2 - } - Text { - id: text1; objectName: "text1" - y: 200; - text: "Hello" - } - Text { - id: text2; objectName: "text2" - anchors.baseline: text1.baseline - anchors.left: text1.right - text: "World" - } -} diff --git a/tests/auto/declarative/anchors/data/centerin.qml b/tests/auto/declarative/anchors/data/centerin.qml deleted file mode 100644 index 09b97f6..0000000 --- a/tests/auto/declarative/anchors/data/centerin.qml +++ /dev/null @@ -1,12 +0,0 @@ -import Qt 4.6 - -Rectangle { - width: 200; height: 200 - Rectangle { - objectName: "centered" - width: 50; height: 50; color: "blue" - anchors.centerIn: parent; - anchors.verticalCenterOffset: 30 - anchors.horizontalCenterOffset: 10 - } -} diff --git a/tests/auto/declarative/anchors/data/crash1.qml b/tests/auto/declarative/anchors/data/crash1.qml deleted file mode 100644 index fd9dc55..0000000 --- a/tests/auto/declarative/anchors/data/crash1.qml +++ /dev/null @@ -1,11 +0,0 @@ -import Qt 4.6 - -Column { - Text { - text: "foo" - anchors.fill: parent - } - Text { - text: "bar" - } -} diff --git a/tests/auto/declarative/anchors/data/fill.qml b/tests/auto/declarative/anchors/data/fill.qml deleted file mode 100644 index 902465c..0000000 --- a/tests/auto/declarative/anchors/data/fill.qml +++ /dev/null @@ -1,14 +0,0 @@ -import Qt 4.6 - -Rectangle { - width: 200; height: 200 - Rectangle { - objectName: "filler" - width: 50; height: 50; color: "blue" - anchors.fill: parent; - anchors.leftMargin: 10; - anchors.rightMargin: 20; - anchors.topMargin: 30; - anchors.bottomMargin: 40; - } -} diff --git a/tests/auto/declarative/anchors/data/loop1.qml b/tests/auto/declarative/anchors/data/loop1.qml deleted file mode 100644 index a266612..0000000 --- a/tests/auto/declarative/anchors/data/loop1.qml +++ /dev/null @@ -1,8 +0,0 @@ -import Qt 4.6 - -Rectangle { - id: rect - width: 120; height: 200; color: "white" - Text { id: text1; anchors.right: text2.right; text: "Hello" } - Text { id: text2; anchors.right: text1.right; anchors.rightMargin: 10; text: "World" } -} diff --git a/tests/auto/declarative/anchors/data/loop2.qml b/tests/auto/declarative/anchors/data/loop2.qml deleted file mode 100644 index acb57cd..0000000 --- a/tests/auto/declarative/anchors/data/loop2.qml +++ /dev/null @@ -1,20 +0,0 @@ -import Qt 4.6 - -Rectangle { - id: container; - width: 600; - height: 600; - - Image { - id: image1 - source: "http://labs.trolltech.com/blogs/wp-content/uploads/2009/03/3311388091_ac2a257feb.jpg" - anchors.right: image2.left - } - - Image { - id: image2 - source: "http://labs.trolltech.com/blogs/wp-content/uploads/2009/03/oslo_groupphoto.jpg" - anchors.left: image1.right - anchors.leftMargin: 20 - } -} diff --git a/tests/auto/declarative/anchors/data/margins.qml b/tests/auto/declarative/anchors/data/margins.qml deleted file mode 100644 index 4a29e77..0000000 --- a/tests/auto/declarative/anchors/data/margins.qml +++ /dev/null @@ -1,13 +0,0 @@ -import Qt 4.6 - -Rectangle { - width: 200; height: 200 - Rectangle { - objectName: "filler" - width: 50; height: 50; color: "blue" - anchors.fill: parent; - anchors.margins: 10 - anchors.leftMargin: 5 - anchors.topMargin: 6 - } -} diff --git a/tests/auto/declarative/anchors/tst_anchors.cpp b/tests/auto/declarative/anchors/tst_anchors.cpp deleted file mode 100644 index 4cbfc94..0000000 --- a/tests/auto/declarative/anchors/tst_anchors.cpp +++ /dev/null @@ -1,459 +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 -#include -#include -#include -#include -#include -#include -#include - -Q_DECLARE_METATYPE(QmlGraphicsAnchors::UsedAnchor) -Q_DECLARE_METATYPE(QmlGraphicsAnchorLine::AnchorLine) - - -class tst_anchors : public QObject -{ - Q_OBJECT -public: - tst_anchors() {} - - template - T *findItem(QmlGraphicsItem *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 -T *tst_anchors::findItem(QmlGraphicsItem *parent, const QString &objectName) -{ - const QMetaObject &mo = T::staticMetaObject; - QList children = parent->childItems(); - for (int i = 0; i < children.count(); ++i) { - QmlGraphicsItem *item = qobject_cast(children.at(i)->toGraphicsObject()); - if (item) { - if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) { - return static_cast(item); - } - item = findItem(item, objectName); - if (item) - return static_cast(item); - } - } - - return 0; -} - -void tst_anchors::basicAnchors() -{ - QmlView *view = new QmlView; - view->setUrl(QUrl::fromLocalFile(SRCDIR "/data/anchors.qml")); - - view->execute(); - qApp->processEvents(); - - //sibling horizontal - QCOMPARE(findItem(view->root(), QLatin1String("rect1"))->x(), 26.0); - QCOMPARE(findItem(view->root(), QLatin1String("rect2"))->x(), 122.0); - QCOMPARE(findItem(view->root(), QLatin1String("rect3"))->x(), 74.0); - QCOMPARE(findItem(view->root(), QLatin1String("rect4"))->x(), 16.0); - QCOMPARE(findItem(view->root(), QLatin1String("rect5"))->x(), 112.0); - QCOMPARE(findItem(view->root(), QLatin1String("rect6"))->x(), 64.0); - - //parent horizontal - QCOMPARE(findItem(view->root(), QLatin1String("rect7"))->x(), 0.0); - QCOMPARE(findItem(view->root(), QLatin1String("rect8"))->x(), 240.0); - QCOMPARE(findItem(view->root(), QLatin1String("rect9"))->x(), 120.0); - QCOMPARE(findItem(view->root(), QLatin1String("rect10"))->x(), -10.0); - QCOMPARE(findItem(view->root(), QLatin1String("rect11"))->x(), 230.0); - QCOMPARE(findItem(view->root(), QLatin1String("rect12"))->x(), 110.0); - - //vertical - QCOMPARE(findItem(view->root(), QLatin1String("rect13"))->y(), 20.0); - QCOMPARE(findItem(view->root(), QLatin1String("rect14"))->y(), 155.0); - - //stretch - QCOMPARE(findItem(view->root(), QLatin1String("rect15"))->x(), 26.0); - QCOMPARE(findItem(view->root(), QLatin1String("rect15"))->width(), 96.0); - QCOMPARE(findItem(view->root(), QLatin1String("rect16"))->x(), 26.0); - QCOMPARE(findItem(view->root(), QLatin1String("rect16"))->width(), 192.0); - QCOMPARE(findItem(view->root(), QLatin1String("rect17"))->x(), -70.0); - QCOMPARE(findItem(view->root(), QLatin1String("rect17"))->width(), 192.0); - - //vertical stretch - QCOMPARE(findItem(view->root(), QLatin1String("rect18"))->y(), 20.0); - QCOMPARE(findItem(view->root(), QLatin1String("rect18"))->height(), 40.0); - - //more parent horizontal - QCOMPARE(findItem(view->root(), QLatin1String("rect19"))->x(), 115.0); - QCOMPARE(findItem(view->root(), QLatin1String("rect20"))->x(), 235.0); - QCOMPARE(findItem(view->root(), QLatin1String("rect21"))->x(), -5.0); - - //centerIn - QCOMPARE(findItem(view->root(), QLatin1String("rect22"))->x(), 69.0); - QCOMPARE(findItem(view->root(), QLatin1String("rect22"))->y(), 5.0); - - //margins - QCOMPARE(findItem(view->root(), QLatin1String("rect23"))->x(), 31.0); - QCOMPARE(findItem(view->root(), QLatin1String("rect23"))->y(), 5.0); - QCOMPARE(findItem(view->root(), QLatin1String("rect23"))->width(), 86.0); - QCOMPARE(findItem(view->root(), QLatin1String("rect23"))->height(), 10.0); - - // offsets - QCOMPARE(findItem(view->root(), QLatin1String("rect24"))->x(), 26.0); - QCOMPARE(findItem(view->root(), QLatin1String("rect25"))->y(), 60.0); - QCOMPARE(findItem(view->root(), QLatin1String("rect26"))->y(), 5.0); - - //baseline - QmlGraphicsText *text1 = findItem(view->root(), QLatin1String("text1")); - QmlGraphicsText *text2 = findItem(view->root(), QLatin1String("text2")); - QCOMPARE(text1->y(), text2->y()); - - delete view; -} - -// mostly testing that we don't crash -void tst_anchors::loops() -{ - { - QmlView *view = new QmlView; - - view->setUrl(QUrl::fromLocalFile(SRCDIR "/data/loop1.qml")); - - QString expect = "QML Text (" + view->url().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->setUrl(QUrl::fromLocalFile(SRCDIR "/data/loop2.qml")); - - QString expect = "QML Image (" + view->url().toString() + ":8:3" + ") Possible anchor loop detected on horizontal anchor."; - QTest::ignoreMessage(QtWarningMsg, expect.toLatin1()); - view->execute(); - qApp->processEvents(); - - delete view; - } -} - -void tst_anchors::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_anchors::illegalSets_data() -{ - QTest::addColumn("qml"); - QTest::addColumn("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) Can't 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) Can't 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) Can't 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) Can't 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) Can't 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 can't 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) Can't 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) Can't 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) Can't 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) Can't 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) Can't anchor to an item that isn't a parent or sibling."; -} - -void tst_anchors::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_anchors::reset_data() -{ - QTest::addColumn("side"); - QTest::addColumn("anchorLine"); - QTest::addColumn("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_anchors::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_anchors::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) Can't anchor to a null item."); - QVERIFY(p.write(item->anchors(), qVariantFromValue(anchor))); - - delete item; -} - -void tst_anchors::nullItem_data() -{ - QTest::addColumn("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_anchors::crash1() -{ - QmlView *view = new QmlView; - - view->setUrl(QUrl::fromLocalFile(SRCDIR "/data/crash1.qml")); - - QString expect = "QML Text (" + view->url().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_anchors::fill() -{ - QmlView *view = new QmlView; - - view->setUrl(QUrl::fromLocalFile(SRCDIR "/data/fill.qml")); - - view->execute(); - qApp->processEvents(); - QmlGraphicsRectangle* rect = findItem(view->root(), 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_anchors::centerIn() -{ - QmlView *view = new QmlView; - - view->setUrl(QUrl::fromLocalFile(SRCDIR "/data/centerin.qml")); - - view->execute(); - qApp->processEvents(); - QmlGraphicsRectangle* rect = findItem(view->root(), 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_anchors::margins() -{ - QmlView *view = new QmlView; - - view->setUrl(QUrl::fromLocalFile(SRCDIR "/data/margins.qml")); - - view->execute(); - qApp->processEvents(); - QmlGraphicsRectangle* rect = findItem(view->root(), 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_anchors) - -#include "tst_anchors.moc" diff --git a/tests/auto/declarative/animatedimage/animatedimage.pro b/tests/auto/declarative/animatedimage/animatedimage.pro deleted file mode 100644 index 5a8ec6c..0000000 --- a/tests/auto/declarative/animatedimage/animatedimage.pro +++ /dev/null @@ -1,7 +0,0 @@ -load(qttest_p4) -contains(QT_CONFIG,declarative): QT += declarative network -HEADERS += ../shared/testhttpserver.h -SOURCES += tst_animatedimage.cpp ../shared/testhttpserver.cpp -macx:CONFIG -= app_bundle - -DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/animatedimage/data/colors.gif b/tests/auto/declarative/animatedimage/data/colors.gif deleted file mode 100644 index 1270bfa..0000000 Binary files a/tests/auto/declarative/animatedimage/data/colors.gif and /dev/null differ diff --git a/tests/auto/declarative/animatedimage/data/colors.qml b/tests/auto/declarative/animatedimage/data/colors.qml deleted file mode 100644 index 5bada34..0000000 --- a/tests/auto/declarative/animatedimage/data/colors.qml +++ /dev/null @@ -1,5 +0,0 @@ -import Qt 4.6 - -AnimatedImage { - source: "colors.gif" -} diff --git a/tests/auto/declarative/animatedimage/data/stickman.gif b/tests/auto/declarative/animatedimage/data/stickman.gif deleted file mode 100644 index 7c4cd18..0000000 Binary files a/tests/auto/declarative/animatedimage/data/stickman.gif and /dev/null differ diff --git a/tests/auto/declarative/animatedimage/data/stickman.qml b/tests/auto/declarative/animatedimage/data/stickman.qml deleted file mode 100644 index a70db5d..0000000 --- a/tests/auto/declarative/animatedimage/data/stickman.qml +++ /dev/null @@ -1,5 +0,0 @@ -import Qt 4.6 - -AnimatedImage { - source: "stickman.gif" -} diff --git a/tests/auto/declarative/animatedimage/data/stickmanpause.qml b/tests/auto/declarative/animatedimage/data/stickmanpause.qml deleted file mode 100644 index 7ab17d4..0000000 --- a/tests/auto/declarative/animatedimage/data/stickmanpause.qml +++ /dev/null @@ -1,7 +0,0 @@ -import Qt 4.6 - -AnimatedImage { - source: "stickman.gif" - paused: true - currentFrame: 2 -} diff --git a/tests/auto/declarative/animatedimage/data/stickmanstopped.qml b/tests/auto/declarative/animatedimage/data/stickmanstopped.qml deleted file mode 100644 index 53b0c3a..0000000 --- a/tests/auto/declarative/animatedimage/data/stickmanstopped.qml +++ /dev/null @@ -1,6 +0,0 @@ -import Qt 4.6 - -AnimatedImage { - source: "stickman.gif" - playing: false -} diff --git a/tests/auto/declarative/animatedimage/tst_animatedimage.cpp b/tests/auto/declarative/animatedimage/tst_animatedimage.cpp deleted file mode 100644 index ee072c8..0000000 --- a/tests/auto/declarative/animatedimage/tst_animatedimage.cpp +++ /dev/null @@ -1,191 +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 -#include -#include -#include -#include -#include -#include - -#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_animatedimage : public QObject -{ - Q_OBJECT -public: - tst_animatedimage() {} - -private slots: - void play(); - void pause(); - void stopped(); - void setFrame(); - void frameCount(); - void remote(); - void remote_data(); - void invalidSource(); -}; - -void tst_animatedimage::play() -{ - QmlEngine engine; - QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/stickman.qml")); - QmlGraphicsAnimatedImage *anim = qobject_cast(component.create()); - QVERIFY(anim); - QVERIFY(anim->isPlaying()); - - delete anim; -} - -void tst_animatedimage::pause() -{ - QmlEngine engine; - QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/stickmanpause.qml")); - QmlGraphicsAnimatedImage *anim = qobject_cast(component.create()); - QVERIFY(anim); - QVERIFY(anim->isPlaying()); - QVERIFY(anim->isPaused()); - - delete anim; -} - -void tst_animatedimage::stopped() -{ - QmlEngine engine; - QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/stickmanstopped.qml")); - QmlGraphicsAnimatedImage *anim = qobject_cast(component.create()); - QVERIFY(anim); - QVERIFY(!anim->isPlaying()); - QCOMPARE(anim->currentFrame(), 0); - - delete anim; -} - -void tst_animatedimage::setFrame() -{ - QmlEngine engine; - QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/stickmanpause.qml")); - QmlGraphicsAnimatedImage *anim = qobject_cast(component.create()); - QVERIFY(anim); - QVERIFY(anim->isPlaying()); - QCOMPARE(anim->currentFrame(), 2); - - delete anim; -} - -void tst_animatedimage::frameCount() -{ - QmlEngine engine; - QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/colors.qml")); - QmlGraphicsAnimatedImage *anim = qobject_cast(component.create()); - QVERIFY(anim); - QVERIFY(anim->isPlaying()); - QCOMPARE(anim->frameCount(), 3); - - delete anim; -} - -void tst_animatedimage::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(component.create()); - QVERIFY(anim); - - TRY_WAIT(anim->isPlaying()); - if (paused) { - TRY_WAIT(anim->isPaused()); - QCOMPARE(anim->currentFrame(), 2); - } - - delete anim; -} - -void tst_animatedimage::remote_data() -{ - QTest::addColumn("fileName"); - QTest::addColumn("paused"); - - QTest::newRow("playing") << "stickman.qml" << false; - QTest::newRow("paused") << "stickmanpause.qml" << true; -} - -void tst_animatedimage::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(component.create()); - QVERIFY(anim); - - QVERIFY(!anim->isPlaying()); - QVERIFY(!anim->isPaused()); - QCOMPARE(anim->currentFrame(), 0); - QCOMPARE(anim->frameCount(), 0); -} - -QTEST_MAIN(tst_animatedimage) - -#include "tst_animatedimage.moc" diff --git a/tests/auto/declarative/animations/animations.pro b/tests/auto/declarative/animations/animations.pro deleted file mode 100644 index e13ecb9..0000000 --- a/tests/auto/declarative/animations/animations.pro +++ /dev/null @@ -1,6 +0,0 @@ -load(qttest_p4) -contains(QT_CONFIG,declarative): QT += declarative -SOURCES += tst_animations.cpp -macx:CONFIG -= app_bundle - -DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/animations/data/attached.qml b/tests/auto/declarative/animations/data/attached.qml deleted file mode 100644 index 0fb6f8c..0000000 --- a/tests/auto/declarative/animations/data/attached.qml +++ /dev/null @@ -1,34 +0,0 @@ -import Qt 4.6 - -Rectangle { - width: 180; height: 200; - - Component { - id: delegate - Rectangle { - id: wrapper - width: 180; height: 200 - color: "blue" - - states: State { - name: "otherState" - PropertyChanges { target: wrapper; color: "green" } - } - - transitions: Transition { - PropertyAction { target: wrapper; property: "ListView.delayRemove"; value: true } - ScriptAction { script: console.log(ListView.delayRemove ? "on" : "off") } - } - - Component.onCompleted: { - console.log(ListView.delayRemove ? "on" : "off"); - wrapper.state = "otherState" - } - } - } - - ListView { - model: 1 - delegate: delegate - } -} diff --git a/tests/auto/declarative/animations/data/badproperty1.qml b/tests/auto/declarative/animations/data/badproperty1.qml deleted file mode 100644 index d31cae9..0000000 --- a/tests/auto/declarative/animations/data/badproperty1.qml +++ /dev/null @@ -1,21 +0,0 @@ -import Qt 4.6 - -Rectangle { - id: wrapper - width: 240 - height: 320 - Rectangle { - id: myRect - color: "red" - width: 50; height: 50 - x: 100; y: 100 - } - states: State { - name: "state1" - PropertyChanges { target: myRect; border.color: "blue" } - } - transitions: Transition { - ColorAnimation { target: myRect; to: "red"; property: "border.colr"; duration: 1000 } - } - Component.onCompleted: if (wrapper.state == "state1") wrapper.state = ""; else wrapper.state = "state1"; -} diff --git a/tests/auto/declarative/animations/data/badproperty2.qml b/tests/auto/declarative/animations/data/badproperty2.qml deleted file mode 100644 index 3b8b111..0000000 --- a/tests/auto/declarative/animations/data/badproperty2.qml +++ /dev/null @@ -1,21 +0,0 @@ -import Qt 4.6 - -Rectangle { - id: wrapper - width: 240 - height: 320 - Rectangle { - id: myRect - color: "red" - width: 50; height: 50 - x: 100; y: 100 - } - states: State { - name: "state1" - PropertyChanges { target: myRect; border.color: "blue" } - } - transitions: Transition { - ColorAnimation { target: myRect; to: "red"; property: "border"; duration: 1000 } - } - Component.onCompleted: if (wrapper.state == "state1") wrapper.state = ""; else wrapper.state = "state1"; -} diff --git a/tests/auto/declarative/animations/data/badtype1.qml b/tests/auto/declarative/animations/data/badtype1.qml deleted file mode 100644 index 6381df3..0000000 --- a/tests/auto/declarative/animations/data/badtype1.qml +++ /dev/null @@ -1,12 +0,0 @@ -import Qt 4.6 - -Rectangle { - width: 240 - height: 320 - Rectangle { - color: "red" - width: 50; height: 50 - x: 100; y: 100 - x: PropertyAnimation { from: "blue"; to: "green"; } - } -} diff --git a/tests/auto/declarative/animations/data/badtype2.qml b/tests/auto/declarative/animations/data/badtype2.qml deleted file mode 100644 index 8d57e41..0000000 --- a/tests/auto/declarative/animations/data/badtype2.qml +++ /dev/null @@ -1,12 +0,0 @@ -import Qt 4.6 - -Rectangle { - width: 240 - height: 320 - Rectangle { - color: "red" - width: 50; height: 50 - x: 100; y: 100 - x: NumberAnimation { from: "blue"; to: "green"; } - } -} diff --git a/tests/auto/declarative/animations/data/badtype3.qml b/tests/auto/declarative/animations/data/badtype3.qml deleted file mode 100644 index c4867c3..0000000 --- a/tests/auto/declarative/animations/data/badtype3.qml +++ /dev/null @@ -1,12 +0,0 @@ -import Qt 4.6 - -Rectangle { - width: 240 - height: 320 - Rectangle { - color: "red" - color: ColorAnimation { from: 10; to: 15; } - width: 50; height: 50 - x: 100; y: 100 - } -} diff --git a/tests/auto/declarative/animations/data/badtype4.qml b/tests/auto/declarative/animations/data/badtype4.qml deleted file mode 100644 index a4cf265..0000000 --- a/tests/auto/declarative/animations/data/badtype4.qml +++ /dev/null @@ -1,27 +0,0 @@ -import Qt 4.6 - -Rectangle { - id: wrapper - width: 240 - height: 320 - Rectangle { - id: myRect - objectName: "MyRect" - color: "red" - width: 50; height: 50 - x: 100; y: 100 - MouseRegion { - anchors.fill: parent - onClicked: if (wrapper.state == "state1") wrapper.state = ""; else wrapper.state = "state1"; - } - } - states: State { - name: "state1" - PropertyChanges { target: myRect; x: 200; color: "blue" } - } - transitions: Transition { - //comment out each in turn to make sure each only animates the relevant property - ColorAnimation { matchProperties: "x,color"; duration: 1000 } //x is real, color is color - NumberAnimation { matchProperties: "x,color"; duration: 1000 } //x is real, color is color - } -} diff --git a/tests/auto/declarative/animations/data/dotproperty.qml b/tests/auto/declarative/animations/data/dotproperty.qml deleted file mode 100644 index 369491f..0000000 --- a/tests/auto/declarative/animations/data/dotproperty.qml +++ /dev/null @@ -1,24 +0,0 @@ -import Qt 4.6 - -Rectangle { - id: wrapper - width: 240 - height: 320 - Rectangle { - id: myRect - color: "red" - width: 50; height: 50 - x: 100; y: 100 - MouseRegion { - anchors.fill: parent - onClicked: if (wrapper.state == "state1") wrapper.state = ""; else wrapper.state = "state1"; - } - } - states: State { - name: "state1" - PropertyChanges { target: myRect; border.color: "blue" } - } - transitions: Transition { - ColorAnimation { matchProperties: "border.color"; duration: 1000 } - } -} diff --git a/tests/auto/declarative/animations/data/mixedtype1.qml b/tests/auto/declarative/animations/data/mixedtype1.qml deleted file mode 100644 index 87f4f16..0000000 --- a/tests/auto/declarative/animations/data/mixedtype1.qml +++ /dev/null @@ -1,25 +0,0 @@ -import Qt 4.6 - -Rectangle { - id: wrapper - width: 240 - height: 320 - Rectangle { - id: myRect - objectName: "MyRect" - color: "red" - width: 50; height: 50 - x: 100; y: 100 - MouseRegion { - anchors.fill: parent - onClicked: if (wrapper.state == "state1") wrapper.state = ""; else wrapper.state = "state1"; - } - } - states: State { - name: "state1" - PropertyChanges { target: myRect; x: 200; border.width: 10 } - } - transitions: Transition { - PropertyAnimation { matchProperties: "x,border.width"; duration: 1000 } //x is real, border.width is int - } -} diff --git a/tests/auto/declarative/animations/data/mixedtype2.qml b/tests/auto/declarative/animations/data/mixedtype2.qml deleted file mode 100644 index d555abd..0000000 --- a/tests/auto/declarative/animations/data/mixedtype2.qml +++ /dev/null @@ -1,25 +0,0 @@ -import Qt 4.6 - -Rectangle { - id: wrapper - width: 240 - height: 320 - Rectangle { - id: myRect - objectName: "MyRect" - color: "red" - width: 50; height: 50 - x: 100; y: 100 - MouseRegion { - anchors.fill: parent - onClicked: if (wrapper.state == "state1") wrapper.state = ""; else wrapper.state = "state1"; - } - } - states: State { - name: "state1" - PropertyChanges { target: myRect; x: 200; color: "blue" } - } - transitions: Transition { - PropertyAnimation { matchProperties: "x,color"; duration: 1000 } //x is real, color is color - } -} diff --git a/tests/auto/declarative/animations/data/properties.qml b/tests/auto/declarative/animations/data/properties.qml deleted file mode 100644 index 7e73f57..0000000 --- a/tests/auto/declarative/animations/data/properties.qml +++ /dev/null @@ -1,14 +0,0 @@ -import Qt 4.6 - -Rectangle { - width: 400 - height: 400 - Rectangle { - id: theRect - objectName: "TheRect" - color: "red" - width: 50; height: 50 - x: 100; y: 100 - x: NumberAnimation { to: 200 } - } -} diff --git a/tests/auto/declarative/animations/data/properties2.qml b/tests/auto/declarative/animations/data/properties2.qml deleted file mode 100644 index 86568ca..0000000 --- a/tests/auto/declarative/animations/data/properties2.qml +++ /dev/null @@ -1,14 +0,0 @@ -import Qt 4.6 - -Rectangle { - width: 400 - height: 400 - Rectangle { - id: theRect - objectName: "TheRect" - color: "red" - width: 50; height: 50 - x: 100; y: 100 - x: NumberAnimation { matchTargets: theRect; matchProperties: "x"; to: 200; } - } -} diff --git a/tests/auto/declarative/animations/data/properties3.qml b/tests/auto/declarative/animations/data/properties3.qml deleted file mode 100644 index ff08885..0000000 --- a/tests/auto/declarative/animations/data/properties3.qml +++ /dev/null @@ -1,14 +0,0 @@ -import Qt 4.6 - -Rectangle { - width: 400 - height: 400 - Rectangle { - id: theRect - objectName: "TheRect" - color: "red" - width: 50; height: 50 - x: 100; y: 100 - x: NumberAnimation { target: theRect; property: "x"; to: 300; } - } -} diff --git a/tests/auto/declarative/animations/data/properties4.qml b/tests/auto/declarative/animations/data/properties4.qml deleted file mode 100644 index dab7e5f..0000000 --- a/tests/auto/declarative/animations/data/properties4.qml +++ /dev/null @@ -1,14 +0,0 @@ -import Qt 4.6 - -Rectangle { - width: 400 - height: 400 - Rectangle { - id: theRect - objectName: "TheRect" - color: "red" - width: 50; height: 50 - x: 100; y: 100 - x: NumberAnimation { target: theRect; property: "y"; to: 200; } - } -} diff --git a/tests/auto/declarative/animations/data/properties5.qml b/tests/auto/declarative/animations/data/properties5.qml deleted file mode 100644 index 56e0be8..0000000 --- a/tests/auto/declarative/animations/data/properties5.qml +++ /dev/null @@ -1,14 +0,0 @@ -import Qt 4.6 - -Rectangle { - width: 400 - height: 400 - Rectangle { - id: theRect - objectName: "TheRect" - color: "red" - width: 50; height: 50 - x: 100; y: 100 - x: NumberAnimation { matchTargets: theRect; matchProperties: "y"; to: 200; } - } -} diff --git a/tests/auto/declarative/animations/data/propertiesTransition.qml b/tests/auto/declarative/animations/data/propertiesTransition.qml deleted file mode 100644 index 75603b9..0000000 --- a/tests/auto/declarative/animations/data/propertiesTransition.qml +++ /dev/null @@ -1,29 +0,0 @@ -import Qt 4.6 - -Rectangle { - width: 400 - height: 400 - Rectangle { - id: theRect - objectName: "TheRect" - color: "red" - width: 50; height: 50 - x: 100; y: 100 - } - - states: State { - name: "moved" - PropertyChanges { - target: theRect - x: 200 - } - } - transitions: Transition { - NumberAnimation { matchTargets: theRect; matchProperties: "x" } - } - - MouseRegion { - anchors.fill: parent - onClicked: parent.state = "moved" - } -} diff --git a/tests/auto/declarative/animations/data/propertiesTransition2.qml b/tests/auto/declarative/animations/data/propertiesTransition2.qml deleted file mode 100644 index ae59157..0000000 --- a/tests/auto/declarative/animations/data/propertiesTransition2.qml +++ /dev/null @@ -1,29 +0,0 @@ -import Qt 4.6 - -Rectangle { - width: 400 - height: 400 - Rectangle { - id: theRect - objectName: "TheRect" - color: "red" - width: 50; height: 50 - x: 100; y: 100 - } - - states: State { - name: "moved" - PropertyChanges { - target: theRect - x: 200 - } - } - transitions: Transition { - NumberAnimation { target: theRect; property: "y"; to: 200 } - } - - MouseRegion { - anchors.fill: parent - onClicked: parent.state = "moved" - } -} diff --git a/tests/auto/declarative/animations/data/propertiesTransition3.qml b/tests/auto/declarative/animations/data/propertiesTransition3.qml deleted file mode 100644 index eedba7b..0000000 --- a/tests/auto/declarative/animations/data/propertiesTransition3.qml +++ /dev/null @@ -1,29 +0,0 @@ -import Qt 4.6 - -Rectangle { - width: 400 - height: 400 - Rectangle { - id: theRect - objectName: "TheRect" - color: "red" - width: 50; height: 50 - x: 100; y: 100 - } - - states: State { - name: "moved" - PropertyChanges { - target: theRect - x: 200 - } - } - transitions: Transition { - NumberAnimation { matchTargets: theRect; matchProperties: "y" } - } - - MouseRegion { - anchors.fill: parent - onClicked: parent.state = "moved" - } -} diff --git a/tests/auto/declarative/animations/data/propertiesTransition4.qml b/tests/auto/declarative/animations/data/propertiesTransition4.qml deleted file mode 100644 index 301f796..0000000 --- a/tests/auto/declarative/animations/data/propertiesTransition4.qml +++ /dev/null @@ -1,29 +0,0 @@ -import Qt 4.6 - -Rectangle { - width: 400 - height: 400 - Rectangle { - id: theRect - objectName: "TheRect" - color: "red" - width: 50; height: 50 - x: 100; y: 100 - } - - states: State { - name: "moved" - PropertyChanges { - target: theRect - x: 200 - } - } - transitions: Transition { - NumberAnimation { target: theRect; matchProperties: "x" } - } - - MouseRegion { - anchors.fill: parent - onClicked: parent.state = "moved" - } -} diff --git a/tests/auto/declarative/animations/data/propertiesTransition5.qml b/tests/auto/declarative/animations/data/propertiesTransition5.qml deleted file mode 100644 index 565c519..0000000 --- a/tests/auto/declarative/animations/data/propertiesTransition5.qml +++ /dev/null @@ -1,29 +0,0 @@ -import Qt 4.6 - -Rectangle { - width: 400 - height: 400 - Rectangle { - id: theRect - objectName: "TheRect" - color: "red" - width: 50; height: 50 - x: 100; y: 100 - } - - states: State { - name: "moved" - PropertyChanges { - target: theRect - x: 200 - } - } - transitions: Transition { - NumberAnimation { matchTargets: theRect; property: "x" } - } - - MouseRegion { - anchors.fill: parent - onClicked: parent.state = "moved" - } -} diff --git a/tests/auto/declarative/animations/data/propertiesTransition6.qml b/tests/auto/declarative/animations/data/propertiesTransition6.qml deleted file mode 100644 index b541dab..0000000 --- a/tests/auto/declarative/animations/data/propertiesTransition6.qml +++ /dev/null @@ -1,29 +0,0 @@ -import Qt 4.6 - -Rectangle { - width: 400 - height: 400 - Rectangle { - id: theRect - objectName: "TheRect" - color: "red" - width: 50; height: 50 - x: 100; y: 100 - } - - states: State { - name: "moved" - PropertyChanges { - target: theRect - x: 200 - } - } - transitions: Transition { - NumberAnimation { matchTargets: theItem; matchProperties: "x" } - } - - MouseRegion { - anchors.fill: parent - onClicked: parent.state = "moved" - } -} diff --git a/tests/auto/declarative/animations/data/valuesource.qml b/tests/auto/declarative/animations/data/valuesource.qml deleted file mode 100644 index c35063d..0000000 --- a/tests/auto/declarative/animations/data/valuesource.qml +++ /dev/null @@ -1,14 +0,0 @@ -import Qt 4.6 - -Rectangle { - width: 400 - height: 400 - Rectangle { - id: rect - objectName: "MyRect" - color: "red" - width: 50; height: 50 - x: 100; y: 100 - x: NumberAnimation { id: anim; objectName: "MyAnim"; to: 200 } - } -} diff --git a/tests/auto/declarative/animations/data/valuesource2.qml b/tests/auto/declarative/animations/data/valuesource2.qml deleted file mode 100644 index 1a60542..0000000 --- a/tests/auto/declarative/animations/data/valuesource2.qml +++ /dev/null @@ -1,14 +0,0 @@ -import Qt 4.6 - -Rectangle { - width: 400 - height: 400 - Rectangle { - id: rect - objectName: "MyRect" - color: "red" - width: 50; height: 50 - x: 100; y: 100 - x: NumberAnimation { id: anim; objectName: "MyAnim"; running: false; to: 200 } - } -} diff --git a/tests/auto/declarative/animations/tst_animations.cpp b/tests/auto/declarative/animations/tst_animations.cpp deleted file mode 100644 index 17085af..0000000 --- a/tests/auto/declarative/animations/tst_animations.cpp +++ /dev/null @@ -1,611 +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 -#include -#include -#include -#include -#include -#include - -class tst_animations : public QObject -{ - Q_OBJECT -public: - tst_animations() {} - -private slots: - 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(); -}; - -#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_animations::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_animations::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_animations::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_animations::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_animations::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_animations::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(50); - 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(50); - animation.stop(); - QVERIFY(rect.x() > x); -} - -void tst_animations::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_animations::badTypes() -{ - //don't crash - { - QmlView *view = new QmlView; - view->setUrl(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(c.create()); - QVERIFY(rect); - - rect->setState("state1"); - QTest::qWait(1000 + 50); - QmlGraphicsRectangle *myRect = rect->findChild("MyRect"); - QVERIFY(myRect); - QCOMPARE(myRect->x(),qreal(200)); - } -} - -void tst_animations::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-existant property \"border.colr\""; - QTest::ignoreMessage(QtWarningMsg, message); - QTest::ignoreMessage(QtWarningMsg, message); // why twice? - QmlGraphicsRectangle *rect = qobject_cast(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); - QTest::ignoreMessage(QtWarningMsg, message); // why twice? - rect = qobject_cast(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_animations::mixedTypes() -{ - //assumes border.width stats a real -- not real robust - { - QmlEngine engine; - QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/mixedtype1.qml")); - QmlGraphicsRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - rect->setState("state1"); - QTest::qWait(500); - QmlGraphicsRectangle *myRect = rect->findChild("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(c.create()); - QVERIFY(rect); - - rect->setState("state1"); - QTest::qWait(500); - QmlGraphicsRectangle *myRect = rect->findChild("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_animations::properties() -{ - const int waitDuration = 300; - { - QmlEngine engine; - QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/properties.qml")); - QmlGraphicsRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - QmlGraphicsRectangle *myRect = rect->findChild("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(c.create()); - QVERIFY(rect); - - QmlGraphicsRectangle *myRect = rect->findChild("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(c.create()); - QVERIFY(rect); - - QmlGraphicsRectangle *myRect = rect->findChild("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(c.create()); - QVERIFY(rect); - - QmlGraphicsRectangle *myRect = rect->findChild("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(c.create()); - QVERIFY(rect); - - QmlGraphicsRectangle *myRect = rect->findChild("TheRect"); - QVERIFY(myRect); - QTest::qWait(waitDuration); - QEXPECT_FAIL("", "QTBUG-8072", Continue); - QTIMED_COMPARE(myRect->x(),qreal(100)); - QTIMED_COMPARE(myRect->y(),qreal(100)); - } -} - -void tst_animations::propertiesTransition() -{ - const int waitDuration = 300; - { - QmlEngine engine; - QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertiesTransition.qml")); - QmlGraphicsRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - rect->setState("moved"); - QmlGraphicsRectangle *myRect = rect->findChild("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(c.create()); - QVERIFY(rect); - - QmlGraphicsRectangle *myRect = rect->findChild("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(c.create()); - QVERIFY(rect); - - QmlGraphicsRectangle *myRect = rect->findChild("TheRect"); - QVERIFY(myRect); - QTest::ignoreMessage(QtWarningMsg, "QML NumberAnimation (" + QUrl::fromLocalFile(SRCDIR "/data/propertiesTransition4.qml").toString().toUtf8() + ":22:9) matchTargets/matchProperties/exclude and target/property are mutually exclusive."); - rect->setState("moved"); - QCOMPARE(myRect->x(),qreal(200)); - } - - { - QmlEngine engine; - QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertiesTransition4.qml")); - QmlGraphicsRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - QmlGraphicsRectangle *myRect = rect->findChild("TheRect"); - QVERIFY(myRect); - QTest::ignoreMessage(QtWarningMsg, "QML NumberAnimation (" + QUrl::fromLocalFile(SRCDIR "/data/propertiesTransition5.qml").toString().toUtf8() + ":22:9) matchTargets/matchProperties/exclude and target/property are mutually exclusive."); - rect->setState("moved"); - QCOMPARE(myRect->x(),qreal(200)); - } - - { - QmlEngine engine; - QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertiesTransition5.qml")); - QmlGraphicsRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - //### should output warning at some point -- theItem doesn't exist - QmlGraphicsRectangle *myRect = rect->findChild("TheRect"); - QVERIFY(myRect); - rect->setState("moved"); - QCOMPARE(myRect->x(),qreal(200)); - } -} - -void tst_animations::easingStringConversion() -{ - QmlNumberAnimation *animation = new QmlNumberAnimation; - animation->setEasing("easeInOutQuad"); - QCOMPARE(animation->easing(),QLatin1String("easeInOutQuad")); - QCOMPARE(static_cast(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve(), QEasingCurve(QEasingCurve::InOutQuad)); - - animation->setEasing("OutQuad"); - QCOMPARE(static_cast(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve(), QEasingCurve(QEasingCurve::OutQuad)); - - animation->setEasing("easeOutBounce(amplitude: 5)"); - QCOMPARE(static_cast(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve().type(), QEasingCurve::OutBounce); - QCOMPARE(static_cast(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve().amplitude(), qreal(5)); - - animation->setEasing("easeOutElastic(amplitude: 5, period: 3)"); - QCOMPARE(static_cast(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve().type(), QEasingCurve::OutElastic); - QCOMPARE(static_cast(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve().amplitude(), qreal(5)); - QCOMPARE(static_cast(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve().period(), qreal(3)); - - animation->setEasing("easeInOutBack(overshoot: 2)"); - QCOMPARE(static_cast(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve().type(), QEasingCurve::InOutBack); - QCOMPARE(static_cast(((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(((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(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve().type(), QEasingCurve::Linear); - - QTest::ignoreMessage(QtWarningMsg, "QML NumberAnimation (unknown location) Unknown easing curve \"NonExistantEase\""); - animation->setEasing("NonExistantEase"); - QCOMPARE(static_cast(((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(((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(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve().type(), QEasingCurve::InOutElastic); - QVERIFY(static_cast(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve().amplitude() != qreal(5)); - - QTest::ignoreMessage(QtWarningMsg, "QML NumberAnimation (unknown location) Unknown easing parameter \"nonexistantproperty\""); - animation->setEasing("easeOutQuad(nonexistantproperty: 12)"); - QCOMPARE(static_cast(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve().type(), QEasingCurve::OutQuad); - - delete animation; -} - -void tst_animations::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_animations::attached() -{ - QmlEngine engine; - - QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/attached.qml")); - QTest::ignoreMessage(QtDebugMsg, "off"); - QTest::ignoreMessage(QtDebugMsg, "on"); - QmlGraphicsRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); -} - -void tst_animations::propertyValueSourceDefaultStart() -{ - { - QmlEngine engine; - - QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/valuesource.qml")); - - QmlGraphicsRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - QmlAbstractAnimation *myAnim = rect->findChild("MyAnim"); - QVERIFY(myAnim); - QVERIFY(myAnim->isRunning()); - } - - { - QmlEngine engine; - - QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/valuesource2.qml")); - - QmlGraphicsRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - QmlAbstractAnimation *myAnim = rect->findChild("MyAnim"); - QVERIFY(myAnim); - QVERIFY(myAnim->isRunning() == false); - } -} - -QTEST_MAIN(tst_animations) - -#include "tst_animations.moc" diff --git a/tests/auto/declarative/behaviors/behaviors.pro b/tests/auto/declarative/behaviors/behaviors.pro deleted file mode 100644 index 8886b0c..0000000 --- a/tests/auto/declarative/behaviors/behaviors.pro +++ /dev/null @@ -1,6 +0,0 @@ -load(qttest_p4) -contains(QT_CONFIG,declarative): QT += declarative -SOURCES += tst_behaviors.cpp -macx:CONFIG -= app_bundle - -DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/behaviors/data/binding.qml b/tests/auto/declarative/behaviors/data/binding.qml deleted file mode 100644 index e0c3321..0000000 --- a/tests/auto/declarative/behaviors/data/binding.qml +++ /dev/null @@ -1,26 +0,0 @@ -import Qt 4.6 -Rectangle { - width: 400 - height: 400 - property real basex : 0 - property real movedx: 200 - Rectangle { - id: rect - objectName: "MyRect" - width: 100; height: 100; color: "green" - x: basex - x: Behavior { NumberAnimation { duration: 200; } } - } - MouseRegion { - id: clicker - anchors.fill: parent - } - states: State { - name: "moved" - when: clicker.pressed - PropertyChanges { - target: rect - x: movedx - } - } -} diff --git a/tests/auto/declarative/behaviors/data/color.qml b/tests/auto/declarative/behaviors/data/color.qml deleted file mode 100644 index 6598703..0000000 --- a/tests/auto/declarative/behaviors/data/color.qml +++ /dev/null @@ -1,24 +0,0 @@ -import Qt 4.6 -Rectangle { - width: 400 - height: 400 - Rectangle { - id: rect - objectName: "MyRect" - width: 100; height: 100; - color: "green" - color: Behavior { ColorAnimation { duration: 200; } } - } - MouseRegion { - id: clicker - anchors.fill: parent - } - states: State { - name: "red" - when: clicker.pressed - PropertyChanges { - target: rect - color: "red" - } - } -} diff --git a/tests/auto/declarative/behaviors/data/cpptrigger.qml b/tests/auto/declarative/behaviors/data/cpptrigger.qml deleted file mode 100644 index ba507c4..0000000 --- a/tests/auto/declarative/behaviors/data/cpptrigger.qml +++ /dev/null @@ -1,11 +0,0 @@ -import Qt 4.6 -Rectangle { - width: 400 - height: 400 - Rectangle { - id: rect - objectName: "MyRect" - width: 100; height: 100; color: "green" - x: Behavior { NumberAnimation { duration: 200; } } - } -} diff --git a/tests/auto/declarative/behaviors/data/disabled.qml b/tests/auto/declarative/behaviors/data/disabled.qml deleted file mode 100644 index e7b8d51..0000000 --- a/tests/auto/declarative/behaviors/data/disabled.qml +++ /dev/null @@ -1,27 +0,0 @@ -import Qt 4.6 -Rectangle { - width: 400 - height: 400 - Rectangle { - id: rect - objectName: "MyRect" - width: 100; height: 100; color: "green" - x: Behavior { - objectName: "MyBehavior"; - enabled: false - NumberAnimation { duration: 200; } - } - } - MouseRegion { - id: clicker - anchors.fill: parent - } - states: State { - name: "moved" - when: clicker.pressed - PropertyChanges { - target: rect - x: 200 - } - } -} diff --git a/tests/auto/declarative/behaviors/data/empty.qml b/tests/auto/declarative/behaviors/data/empty.qml deleted file mode 100644 index 412e26c..0000000 --- a/tests/auto/declarative/behaviors/data/empty.qml +++ /dev/null @@ -1,23 +0,0 @@ -import Qt 4.6 -Rectangle { - width: 400 - height: 400 - Rectangle { - id: rect - objectName: "MyRect" - width: 100; height: 100; color: "green" - x: Behavior {} - } - MouseRegion { - id: clicker - anchors.fill: parent - } - states: State { - name: "moved" - when: clicker.pressed - PropertyChanges { - target: rect - x: 200 - } - } -} diff --git a/tests/auto/declarative/behaviors/data/groupProperty.qml b/tests/auto/declarative/behaviors/data/groupProperty.qml deleted file mode 100644 index 4f127c1..0000000 --- a/tests/auto/declarative/behaviors/data/groupProperty.qml +++ /dev/null @@ -1,23 +0,0 @@ -import Qt 4.6 -Rectangle { - width: 400 - height: 400 - Rectangle { - id: rect - objectName: "MyRect" - width: 100; height: 100; color: "green" - pos: Behavior { PropertyAnimation { duration: 200; } } - } - MouseRegion { - id: clicker - anchors.fill: parent - } - states: State { - name: "moved" - when: clicker.pressed - PropertyChanges { - target: rect - pos: Qt.point(200,0); - } - } -} diff --git a/tests/auto/declarative/behaviors/data/groupProperty2.qml b/tests/auto/declarative/behaviors/data/groupProperty2.qml deleted file mode 100644 index 19d70b6..0000000 --- a/tests/auto/declarative/behaviors/data/groupProperty2.qml +++ /dev/null @@ -1,23 +0,0 @@ -import Qt 4.6 -Rectangle { - width: 400 - height: 400 - Rectangle { - id: rect - objectName: "MyRect" - width: 100; height: 100; color: "green" - pos.x: Behavior { NumberAnimation { duration: 200; } } - } - MouseRegion { - id: clicker - anchors.fill: parent - } - states: State { - name: "moved" - when: clicker.pressed - PropertyChanges { - target: rect - pos.x: 200; - } - } -} diff --git a/tests/auto/declarative/behaviors/data/loop.qml b/tests/auto/declarative/behaviors/data/loop.qml deleted file mode 100644 index 5f2c057..0000000 --- a/tests/auto/declarative/behaviors/data/loop.qml +++ /dev/null @@ -1,19 +0,0 @@ -import Qt 4.6 -Rectangle { - width: 400 - height: 400 - Rectangle { - id: rect - objectName: "MyRect" - width: 100; height: 100; color: "green" - x: Behavior { NumberAnimation { duration: 200; } } - onXChanged: x = 100; - } - states: State { - name: "moved" - PropertyChanges { - target: rect - x: 200 - } - } -} diff --git a/tests/auto/declarative/behaviors/data/nonSelecting.qml b/tests/auto/declarative/behaviors/data/nonSelecting.qml deleted file mode 100644 index ba36d93..0000000 --- a/tests/auto/declarative/behaviors/data/nonSelecting.qml +++ /dev/null @@ -1,26 +0,0 @@ -import Qt 4.6 -Rectangle { - width: 400 - height: 400 - Rectangle { - id: rect - objectName: "MyRect" - width: 100; height: 100; color: "green" - x: Behavior { - objectName: "MyBehavior"; - NumberAnimation { target: rect; property: "x"; duration: 200; } - } - } - MouseRegion { - id: clicker - anchors.fill: parent - } - states: State { - name: "moved" - when: clicker.pressed - PropertyChanges { - target: rect - x: 200 - } - } -} diff --git a/tests/auto/declarative/behaviors/data/nonSelecting2.qml b/tests/auto/declarative/behaviors/data/nonSelecting2.qml deleted file mode 100644 index e9849eb..0000000 --- a/tests/auto/declarative/behaviors/data/nonSelecting2.qml +++ /dev/null @@ -1,26 +0,0 @@ -import Qt 4.6 -Rectangle { - width: 400 - height: 400 - Rectangle { - id: rect - objectName: "MyRect" - width: 100; height: 100; color: "green" - x: Behavior { - objectName: "MyBehavior"; - NumberAnimation { matchTargets: rect; matchProperties: "y"; duration: 200; } - } - } - MouseRegion { - id: clicker - anchors.fill: parent - } - states: State { - name: "moved" - when: clicker.pressed - PropertyChanges { - target: rect - x: 200 - } - } -} diff --git a/tests/auto/declarative/behaviors/data/parent.qml b/tests/auto/declarative/behaviors/data/parent.qml deleted file mode 100644 index 4f4911b..0000000 --- a/tests/auto/declarative/behaviors/data/parent.qml +++ /dev/null @@ -1,28 +0,0 @@ -import Qt 4.6 -Rectangle { - width: 400 - height: 400 - Rectangle { - id: rect - objectName: "MyRect" - width: 100; height: 100; color: "green" - parent: Behavior { - SequentialAnimation { - PauseAnimation { duration: 200 } - PropertyAction {} - } - } - } - Item { - id: newParent - objectName: "NewParent" - x: 100 - } - states: State { - name: "reparented" - PropertyChanges { - target: rect - parent: newParent - } - } -} diff --git a/tests/auto/declarative/behaviors/data/reassignedAnimation.qml b/tests/auto/declarative/behaviors/data/reassignedAnimation.qml deleted file mode 100644 index 693a595..0000000 --- a/tests/auto/declarative/behaviors/data/reassignedAnimation.qml +++ /dev/null @@ -1,27 +0,0 @@ -import Qt 4.6 -Rectangle { - width: 400 - height: 400 - Rectangle { - id: rect - objectName: "MyRect" - width: 100; height: 100; color: "green" - x: Behavior { - objectName: "MyBehavior" - NumberAnimation { duration: 200 } - NumberAnimation { duration: 1000 } - } - } - MouseRegion { - id: clicker - anchors.fill: parent - } - states: State { - name: "moved" - when: clicker.pressed - PropertyChanges { - target: rect - x: 200 - } - } -} diff --git a/tests/auto/declarative/behaviors/data/scripttrigger.qml b/tests/auto/declarative/behaviors/data/scripttrigger.qml deleted file mode 100644 index 4383a0b..0000000 --- a/tests/auto/declarative/behaviors/data/scripttrigger.qml +++ /dev/null @@ -1,16 +0,0 @@ -import Qt 4.6 -Rectangle { - width: 400 - height: 400 - - onColorChanged: { - rect.x = 200 - } - - Rectangle { - id: rect - objectName: "MyRect" - width: 100; height: 100; color: "green" - x: Behavior { NumberAnimation { duration: 200; } } - } -} diff --git a/tests/auto/declarative/behaviors/data/simple.qml b/tests/auto/declarative/behaviors/data/simple.qml deleted file mode 100644 index 37c3915..0000000 --- a/tests/auto/declarative/behaviors/data/simple.qml +++ /dev/null @@ -1,26 +0,0 @@ -import Qt 4.6 -Rectangle { - width: 400 - height: 400 - Rectangle { - id: rect - objectName: "MyRect" - width: 100; height: 100; color: "green" - x: Behavior { - objectName: "MyBehavior"; - NumberAnimation { duration: 200; } - } - } - MouseRegion { - id: clicker - anchors.fill: parent - } - states: State { - name: "moved" - when: clicker.pressed - PropertyChanges { - target: rect - x: 200 - } - } -} diff --git a/tests/auto/declarative/behaviors/tst_behaviors.cpp b/tests/auto/declarative/behaviors/tst_behaviors.cpp deleted file mode 100644 index fd84596..0000000 --- a/tests/auto/declarative/behaviors/tst_behaviors.cpp +++ /dev/null @@ -1,281 +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 -#include -#include -#include -#include -#include -#include - -class tst_behaviors : public QObject -{ - Q_OBJECT -public: - tst_behaviors() {} - -private slots: - void simpleBehavior(); - void scriptTriggered(); - void cppTriggered(); - void loop(); - void colorBehavior(); - void parentBehavior(); - void replaceBinding(); - //void transitionOverrides(); - void group(); - void emptyBehavior(); - void nonSelectingBehavior(); - void reassignedAnimation(); - void disabled(); -}; - -void tst_behaviors::simpleBehavior() -{ - QmlEngine engine; - QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/simple.qml")); - QmlGraphicsRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - QVERIFY(qobject_cast(rect->findChild("MyBehavior"))->animation()); - - rect->setState("moved"); - QTest::qWait(100); - qreal x = qobject_cast(rect->findChild("MyRect"))->x(); - QVERIFY(x > 0 && x < 200); //i.e. the behavior has been triggered -} - -void tst_behaviors::scriptTriggered() -{ - QmlEngine engine; - QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/scripttrigger.qml")); - QmlGraphicsRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - rect->setColor(QColor("red")); - QTest::qWait(100); - qreal x = qobject_cast(rect->findChild("MyRect"))->x(); - QVERIFY(x > 0 && x < 200); //i.e. the behavior has been triggered -} - -void tst_behaviors::cppTriggered() -{ - QmlEngine engine; - QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/cpptrigger.qml")); - QmlGraphicsRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - QmlGraphicsRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); - QVERIFY(innerRect); - - innerRect->setProperty("x", 200); - QTest::qWait(100); - qreal x = innerRect->x(); - QVERIFY(x > 0 && x < 200); //i.e. the behavior has been triggered -} - -void tst_behaviors::loop() -{ - QmlEngine engine; - QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/loop.qml")); - QmlGraphicsRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - //don't crash - rect->setState("moved"); -} - -void tst_behaviors::colorBehavior() -{ - QmlEngine engine; - QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/color.qml")); - QmlGraphicsRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - rect->setState("red"); - QTest::qWait(100); - QColor color = qobject_cast(rect->findChild("MyRect"))->color(); - QVERIFY(color != QColor("red") && color != QColor("green")); //i.e. the behavior has been triggered -} - -void tst_behaviors::parentBehavior() -{ - QmlEngine engine; - QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/parent.qml")); - QmlGraphicsRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - rect->setState("reparented"); - QTest::qWait(100); - QmlGraphicsItem *newParent = rect->findChild("NewParent"); - QmlGraphicsItem *parent = rect->findChild("MyRect")->parentItem(); - QVERIFY(parent != newParent); - QTest::qWait(300); - parent = rect->findChild("MyRect")->parentItem(); - QVERIFY(parent == newParent); -} - -void tst_behaviors::replaceBinding() -{ - QmlEngine engine; - QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/binding.qml")); - QmlGraphicsRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - rect->setState("moved"); - QTest::qWait(100); - QmlGraphicsRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); - QVERIFY(innerRect); - qreal x = innerRect->x(); - QVERIFY(x > 0 && x < 200); //i.e. the behavior has been triggered - QTest::qWait(300); - QCOMPARE(innerRect->x(), (qreal)200); - rect->setProperty("basex", 10); - QCOMPARE(innerRect->x(), (qreal)200); - rect->setProperty("movedx", 210); - QTest::qWait(300); - QCOMPARE(innerRect->x(), (qreal)210); - - rect->setState(""); - QTest::qWait(100); - x = innerRect->x(); - QVERIFY(x > 10 && x < 210); //i.e. the behavior has been triggered - QTest::qWait(300); - QCOMPARE(innerRect->x(), (qreal)10); - rect->setProperty("movedx", 200); - QCOMPARE(innerRect->x(), (qreal)10); - rect->setProperty("basex", 20); - QTest::qWait(300); - QCOMPARE(innerRect->x(), (qreal)20); -} - -void tst_behaviors::group() -{ - { - QmlEngine engine; - QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/groupProperty.qml")); - QmlGraphicsRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - rect->setState("moved"); - QTest::qWait(100); - qreal x = qobject_cast(rect->findChild("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(c.create()); - QVERIFY(rect); - - rect->setState("moved"); - QTest::qWait(100); - qreal x = qobject_cast(rect->findChild("MyRect"))->x(); - QVERIFY(x > 0 && x < 200); //i.e. the behavior has been triggered - } -} - -void tst_behaviors::emptyBehavior() -{ - QmlEngine engine; - QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/empty.qml")); - QmlGraphicsRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - rect->setState("moved"); - qreal x = qobject_cast(rect->findChild("MyRect"))->x(); - QCOMPARE(x, qreal(200)); //should change immediately -} - -void tst_behaviors::nonSelectingBehavior() -{ - { - QmlEngine engine; - QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/nonSelecting.qml")); - QmlGraphicsRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - rect->setState("moved"); - qreal x = qobject_cast(rect->findChild("MyRect"))->x(); - QCOMPARE(x, qreal(200)); //should change immediately - } - - { - QmlEngine engine; - QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/nonSelecting2.qml")); - QmlGraphicsRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - rect->setState("moved"); - qreal x = qobject_cast(rect->findChild("MyRect"))->x(); - QCOMPARE(x, qreal(200)); //should change immediately - } -} - -void tst_behaviors::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) Can't change the animation assigned to a Behavior.").toUtf8().constData()); - QmlGraphicsRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - QCOMPARE(qobject_cast( - qobject_cast( - rect->findChild("MyBehavior"))->animation())->duration(), 200); -} - -void tst_behaviors::disabled() -{ - QmlEngine engine; - QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/disabled.qml")); - QmlGraphicsRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - QCOMPARE(rect->findChild("MyBehavior")->enabled(), false); - - rect->setState("moved"); - qreal x = qobject_cast(rect->findChild("MyRect"))->x(); - QCOMPARE(x, qreal(200)); //should change immediately - -} - -QTEST_MAIN(tst_behaviors) - -#include "tst_behaviors.moc" diff --git a/tests/auto/declarative/datetimeformatter/datetimeformatter.pro b/tests/auto/declarative/datetimeformatter/datetimeformatter.pro deleted file mode 100644 index 62eb303..0000000 --- a/tests/auto/declarative/datetimeformatter/datetimeformatter.pro +++ /dev/null @@ -1,5 +0,0 @@ -load(qttest_p4) -contains(QT_CONFIG,declarative): QT += declarative -macx:CONFIG -= app_bundle - -SOURCES += tst_datetimeformatter.cpp diff --git a/tests/auto/declarative/datetimeformatter/tst_datetimeformatter.cpp b/tests/auto/declarative/datetimeformatter/tst_datetimeformatter.cpp deleted file mode 100644 index 3302cfa..0000000 --- a/tests/auto/declarative/datetimeformatter/tst_datetimeformatter.cpp +++ /dev/null @@ -1,150 +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 -#include -#include -#include -#include - -class tst_datetimeformatter : public QObject -{ - Q_OBJECT -public: - tst_datetimeformatter() {} - -private slots: - void date(); - void time(); - void dateTime(); -}; - -void tst_datetimeformatter::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(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_datetimeformatter::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(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_datetimeformatter::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(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_datetimeformatter) - -#include "tst_datetimeformatter.moc" diff --git a/tests/auto/declarative/declarative.pro b/tests/auto/declarative/declarative.pro index 7b13b41..8773026 100644 --- a/tests/auto/declarative/declarative.pro +++ b/tests/auto/declarative/declarative.pro @@ -1,18 +1,15 @@ TEMPLATE = subdirs SUBDIRS += \ - anchors \ # Cover - animatedimage \ # Cover - animations \ # Cover - behaviors \ # Cover - datetimeformatter \ # Cover graphicswidgets \ # Cover layouts \ # Cover - numberformatter \ # Cover parserstress \ # Cover qmetaobjectbuilder \ # Cover + qmlanimations \ # Cover + qmlbehaviors \ # Cover qmlbinding \ # Cover qmlconnection \ # Cover qmlcontext \ # Cover + qmldatetimeformatter \ # Cover qmldebug \ # Cover qmldebugclient \ # Cover qmldebugservice \ # Cover @@ -22,6 +19,8 @@ SUBDIRS += \ qmlengine \ # Cover qmlerror \ # Cover qmlfontloader \ # Cover + qmlgraphicsanchors \ # Cover + qmlgraphicsanimatedimage \ # Cover qmlgraphicsimage \ # Cover qmlgraphicsborderimage \ # Cover qmlgraphicsflickable \ # Cover @@ -45,19 +44,20 @@ SUBDIRS += \ qmllistmodel \ # Cover qmlmetaproperty \ # Cover qmlmetatype \ # Cover + qmlnumberformatter \ # Cover qmlpixmapcache \ # Cover qmlpropertymap \ # Cover qmlqt \ # Cover qmlspringfollow \ # Cover + qmlstates \ # Cover qmlsystempalette \ # Cover qmltimer \ # Cover qmlxmllistmodel \ # Cover qpacketprotocol \ # Cover qmlgraphicsrepeater \ # Cover - sql \ # Cover - states \ # Cover - valuetypes \ # Cover - xmlhttprequest # Cover + qmlvaluetypes \ # Cover + qmlxmlhttprequest \ # Cover + sql # Cover # Tests which should run in Pulse diff --git a/tests/auto/declarative/numberformatter/numberformatter.pro b/tests/auto/declarative/numberformatter/numberformatter.pro deleted file mode 100644 index ed7ef22..0000000 --- a/tests/auto/declarative/numberformatter/numberformatter.pro +++ /dev/null @@ -1,5 +0,0 @@ -load(qttest_p4) -contains(QT_CONFIG,declarative): QT += declarative -macx:CONFIG -= app_bundle - -SOURCES += tst_numberformatter.cpp diff --git a/tests/auto/declarative/numberformatter/tst_numberformatter.cpp b/tests/auto/declarative/numberformatter/tst_numberformatter.cpp deleted file mode 100644 index b00e08a..0000000 --- a/tests/auto/declarative/numberformatter/tst_numberformatter.cpp +++ /dev/null @@ -1,222 +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 -#include -#include -#include -#include -#include - -class tst_numberformat : public QObject -{ - Q_OBJECT -public: - tst_numberformat(); - - void init() {} - void initTestCase() {} - - void cleanup() {} - void cleanupTestCase() {} - -private slots: - void text_data(); - void text(); - -private: - QStringList strings; - QStringList formats; - QStringList texts; -}; - -tst_numberformat::tst_numberformat() -{ - 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_numberformat::text_data() -{ - QTest::addColumn("string"); - QTest::addColumn("format"); - QTest::addColumn("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_numberformat::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(formatterComponent.create()); - QVERIFY(formatter != 0); - - QCOMPARE(formatter->format(), format); - QCOMPARE(formatter->text(), text); - - delete formatter; -} - -QTEST_MAIN(tst_numberformat) - -#include "tst_numberformatter.moc" diff --git a/tests/auto/declarative/qmlanimations/data/attached.qml b/tests/auto/declarative/qmlanimations/data/attached.qml new file mode 100644 index 0000000..0fb6f8c --- /dev/null +++ b/tests/auto/declarative/qmlanimations/data/attached.qml @@ -0,0 +1,34 @@ +import Qt 4.6 + +Rectangle { + width: 180; height: 200; + + Component { + id: delegate + Rectangle { + id: wrapper + width: 180; height: 200 + color: "blue" + + states: State { + name: "otherState" + PropertyChanges { target: wrapper; color: "green" } + } + + transitions: Transition { + PropertyAction { target: wrapper; property: "ListView.delayRemove"; value: true } + ScriptAction { script: console.log(ListView.delayRemove ? "on" : "off") } + } + + Component.onCompleted: { + console.log(ListView.delayRemove ? "on" : "off"); + wrapper.state = "otherState" + } + } + } + + ListView { + model: 1 + delegate: delegate + } +} diff --git a/tests/auto/declarative/qmlanimations/data/badproperty1.qml b/tests/auto/declarative/qmlanimations/data/badproperty1.qml new file mode 100644 index 0000000..d31cae9 --- /dev/null +++ b/tests/auto/declarative/qmlanimations/data/badproperty1.qml @@ -0,0 +1,21 @@ +import Qt 4.6 + +Rectangle { + id: wrapper + width: 240 + height: 320 + Rectangle { + id: myRect + color: "red" + width: 50; height: 50 + x: 100; y: 100 + } + states: State { + name: "state1" + PropertyChanges { target: myRect; border.color: "blue" } + } + transitions: Transition { + ColorAnimation { target: myRect; to: "red"; property: "border.colr"; duration: 1000 } + } + Component.onCompleted: if (wrapper.state == "state1") wrapper.state = ""; else wrapper.state = "state1"; +} diff --git a/tests/auto/declarative/qmlanimations/data/badproperty2.qml b/tests/auto/declarative/qmlanimations/data/badproperty2.qml new file mode 100644 index 0000000..3b8b111 --- /dev/null +++ b/tests/auto/declarative/qmlanimations/data/badproperty2.qml @@ -0,0 +1,21 @@ +import Qt 4.6 + +Rectangle { + id: wrapper + width: 240 + height: 320 + Rectangle { + id: myRect + color: "red" + width: 50; height: 50 + x: 100; y: 100 + } + states: State { + name: "state1" + PropertyChanges { target: myRect; border.color: "blue" } + } + transitions: Transition { + ColorAnimation { target: myRect; to: "red"; property: "border"; duration: 1000 } + } + Component.onCompleted: if (wrapper.state == "state1") wrapper.state = ""; else wrapper.state = "state1"; +} diff --git a/tests/auto/declarative/qmlanimations/data/badtype1.qml b/tests/auto/declarative/qmlanimations/data/badtype1.qml new file mode 100644 index 0000000..6381df3 --- /dev/null +++ b/tests/auto/declarative/qmlanimations/data/badtype1.qml @@ -0,0 +1,12 @@ +import Qt 4.6 + +Rectangle { + width: 240 + height: 320 + Rectangle { + color: "red" + width: 50; height: 50 + x: 100; y: 100 + x: PropertyAnimation { from: "blue"; to: "green"; } + } +} diff --git a/tests/auto/declarative/qmlanimations/data/badtype2.qml b/tests/auto/declarative/qmlanimations/data/badtype2.qml new file mode 100644 index 0000000..8d57e41 --- /dev/null +++ b/tests/auto/declarative/qmlanimations/data/badtype2.qml @@ -0,0 +1,12 @@ +import Qt 4.6 + +Rectangle { + width: 240 + height: 320 + Rectangle { + color: "red" + width: 50; height: 50 + x: 100; y: 100 + x: NumberAnimation { from: "blue"; to: "green"; } + } +} diff --git a/tests/auto/declarative/qmlanimations/data/badtype3.qml b/tests/auto/declarative/qmlanimations/data/badtype3.qml new file mode 100644 index 0000000..c4867c3 --- /dev/null +++ b/tests/auto/declarative/qmlanimations/data/badtype3.qml @@ -0,0 +1,12 @@ +import Qt 4.6 + +Rectangle { + width: 240 + height: 320 + Rectangle { + color: "red" + color: ColorAnimation { from: 10; to: 15; } + width: 50; height: 50 + x: 100; y: 100 + } +} diff --git a/tests/auto/declarative/qmlanimations/data/badtype4.qml b/tests/auto/declarative/qmlanimations/data/badtype4.qml new file mode 100644 index 0000000..a4cf265 --- /dev/null +++ b/tests/auto/declarative/qmlanimations/data/badtype4.qml @@ -0,0 +1,27 @@ +import Qt 4.6 + +Rectangle { + id: wrapper + width: 240 + height: 320 + Rectangle { + id: myRect + objectName: "MyRect" + color: "red" + width: 50; height: 50 + x: 100; y: 100 + MouseRegion { + anchors.fill: parent + onClicked: if (wrapper.state == "state1") wrapper.state = ""; else wrapper.state = "state1"; + } + } + states: State { + name: "state1" + PropertyChanges { target: myRect; x: 200; color: "blue" } + } + transitions: Transition { + //comment out each in turn to make sure each only animates the relevant property + ColorAnimation { matchProperties: "x,color"; duration: 1000 } //x is real, color is color + NumberAnimation { matchProperties: "x,color"; duration: 1000 } //x is real, color is color + } +} diff --git a/tests/auto/declarative/qmlanimations/data/dotproperty.qml b/tests/auto/declarative/qmlanimations/data/dotproperty.qml new file mode 100644 index 0000000..369491f --- /dev/null +++ b/tests/auto/declarative/qmlanimations/data/dotproperty.qml @@ -0,0 +1,24 @@ +import Qt 4.6 + +Rectangle { + id: wrapper + width: 240 + height: 320 + Rectangle { + id: myRect + color: "red" + width: 50; height: 50 + x: 100; y: 100 + MouseRegion { + anchors.fill: parent + onClicked: if (wrapper.state == "state1") wrapper.state = ""; else wrapper.state = "state1"; + } + } + states: State { + name: "state1" + PropertyChanges { target: myRect; border.color: "blue" } + } + transitions: Transition { + ColorAnimation { matchProperties: "border.color"; duration: 1000 } + } +} diff --git a/tests/auto/declarative/qmlanimations/data/mixedtype1.qml b/tests/auto/declarative/qmlanimations/data/mixedtype1.qml new file mode 100644 index 0000000..87f4f16 --- /dev/null +++ b/tests/auto/declarative/qmlanimations/data/mixedtype1.qml @@ -0,0 +1,25 @@ +import Qt 4.6 + +Rectangle { + id: wrapper + width: 240 + height: 320 + Rectangle { + id: myRect + objectName: "MyRect" + color: "red" + width: 50; height: 50 + x: 100; y: 100 + MouseRegion { + anchors.fill: parent + onClicked: if (wrapper.state == "state1") wrapper.state = ""; else wrapper.state = "state1"; + } + } + states: State { + name: "state1" + PropertyChanges { target: myRect; x: 200; border.width: 10 } + } + transitions: Transition { + PropertyAnimation { matchProperties: "x,border.width"; duration: 1000 } //x is real, border.width is int + } +} diff --git a/tests/auto/declarative/qmlanimations/data/mixedtype2.qml b/tests/auto/declarative/qmlanimations/data/mixedtype2.qml new file mode 100644 index 0000000..d555abd --- /dev/null +++ b/tests/auto/declarative/qmlanimations/data/mixedtype2.qml @@ -0,0 +1,25 @@ +import Qt 4.6 + +Rectangle { + id: wrapper + width: 240 + height: 320 + Rectangle { + id: myRect + objectName: "MyRect" + color: "red" + width: 50; height: 50 + x: 100; y: 100 + MouseRegion { + anchors.fill: parent + onClicked: if (wrapper.state == "state1") wrapper.state = ""; else wrapper.state = "state1"; + } + } + states: State { + name: "state1" + PropertyChanges { target: myRect; x: 200; color: "blue" } + } + transitions: Transition { + PropertyAnimation { matchProperties: "x,color"; duration: 1000 } //x is real, color is color + } +} diff --git a/tests/auto/declarative/qmlanimations/data/properties.qml b/tests/auto/declarative/qmlanimations/data/properties.qml new file mode 100644 index 0000000..7e73f57 --- /dev/null +++ b/tests/auto/declarative/qmlanimations/data/properties.qml @@ -0,0 +1,14 @@ +import Qt 4.6 + +Rectangle { + width: 400 + height: 400 + Rectangle { + id: theRect + objectName: "TheRect" + color: "red" + width: 50; height: 50 + x: 100; y: 100 + x: NumberAnimation { to: 200 } + } +} diff --git a/tests/auto/declarative/qmlanimations/data/properties2.qml b/tests/auto/declarative/qmlanimations/data/properties2.qml new file mode 100644 index 0000000..86568ca --- /dev/null +++ b/tests/auto/declarative/qmlanimations/data/properties2.qml @@ -0,0 +1,14 @@ +import Qt 4.6 + +Rectangle { + width: 400 + height: 400 + Rectangle { + id: theRect + objectName: "TheRect" + color: "red" + width: 50; height: 50 + x: 100; y: 100 + x: NumberAnimation { matchTargets: theRect; matchProperties: "x"; to: 200; } + } +} diff --git a/tests/auto/declarative/qmlanimations/data/properties3.qml b/tests/auto/declarative/qmlanimations/data/properties3.qml new file mode 100644 index 0000000..ff08885 --- /dev/null +++ b/tests/auto/declarative/qmlanimations/data/properties3.qml @@ -0,0 +1,14 @@ +import Qt 4.6 + +Rectangle { + width: 400 + height: 400 + Rectangle { + id: theRect + objectName: "TheRect" + color: "red" + width: 50; height: 50 + x: 100; y: 100 + x: NumberAnimation { target: theRect; property: "x"; to: 300; } + } +} diff --git a/tests/auto/declarative/qmlanimations/data/properties4.qml b/tests/auto/declarative/qmlanimations/data/properties4.qml new file mode 100644 index 0000000..dab7e5f --- /dev/null +++ b/tests/auto/declarative/qmlanimations/data/properties4.qml @@ -0,0 +1,14 @@ +import Qt 4.6 + +Rectangle { + width: 400 + height: 400 + Rectangle { + id: theRect + objectName: "TheRect" + color: "red" + width: 50; height: 50 + x: 100; y: 100 + x: NumberAnimation { target: theRect; property: "y"; to: 200; } + } +} diff --git a/tests/auto/declarative/qmlanimations/data/properties5.qml b/tests/auto/declarative/qmlanimations/data/properties5.qml new file mode 100644 index 0000000..56e0be8 --- /dev/null +++ b/tests/auto/declarative/qmlanimations/data/properties5.qml @@ -0,0 +1,14 @@ +import Qt 4.6 + +Rectangle { + width: 400 + height: 400 + Rectangle { + id: theRect + objectName: "TheRect" + color: "red" + width: 50; height: 50 + x: 100; y: 100 + x: NumberAnimation { matchTargets: theRect; matchProperties: "y"; to: 200; } + } +} diff --git a/tests/auto/declarative/qmlanimations/data/propertiesTransition.qml b/tests/auto/declarative/qmlanimations/data/propertiesTransition.qml new file mode 100644 index 0000000..75603b9 --- /dev/null +++ b/tests/auto/declarative/qmlanimations/data/propertiesTransition.qml @@ -0,0 +1,29 @@ +import Qt 4.6 + +Rectangle { + width: 400 + height: 400 + Rectangle { + id: theRect + objectName: "TheRect" + color: "red" + width: 50; height: 50 + x: 100; y: 100 + } + + states: State { + name: "moved" + PropertyChanges { + target: theRect + x: 200 + } + } + transitions: Transition { + NumberAnimation { matchTargets: theRect; matchProperties: "x" } + } + + MouseRegion { + anchors.fill: parent + onClicked: parent.state = "moved" + } +} diff --git a/tests/auto/declarative/qmlanimations/data/propertiesTransition2.qml b/tests/auto/declarative/qmlanimations/data/propertiesTransition2.qml new file mode 100644 index 0000000..ae59157 --- /dev/null +++ b/tests/auto/declarative/qmlanimations/data/propertiesTransition2.qml @@ -0,0 +1,29 @@ +import Qt 4.6 + +Rectangle { + width: 400 + height: 400 + Rectangle { + id: theRect + objectName: "TheRect" + color: "red" + width: 50; height: 50 + x: 100; y: 100 + } + + states: State { + name: "moved" + PropertyChanges { + target: theRect + x: 200 + } + } + transitions: Transition { + NumberAnimation { target: theRect; property: "y"; to: 200 } + } + + MouseRegion { + anchors.fill: parent + onClicked: parent.state = "moved" + } +} diff --git a/tests/auto/declarative/qmlanimations/data/propertiesTransition3.qml b/tests/auto/declarative/qmlanimations/data/propertiesTransition3.qml new file mode 100644 index 0000000..eedba7b --- /dev/null +++ b/tests/auto/declarative/qmlanimations/data/propertiesTransition3.qml @@ -0,0 +1,29 @@ +import Qt 4.6 + +Rectangle { + width: 400 + height: 400 + Rectangle { + id: theRect + objectName: "TheRect" + color: "red" + width: 50; height: 50 + x: 100; y: 100 + } + + states: State { + name: "moved" + PropertyChanges { + target: theRect + x: 200 + } + } + transitions: Transition { + NumberAnimation { matchTargets: theRect; matchProperties: "y" } + } + + MouseRegion { + anchors.fill: parent + onClicked: parent.state = "moved" + } +} diff --git a/tests/auto/declarative/qmlanimations/data/propertiesTransition4.qml b/tests/auto/declarative/qmlanimations/data/propertiesTransition4.qml new file mode 100644 index 0000000..301f796 --- /dev/null +++ b/tests/auto/declarative/qmlanimations/data/propertiesTransition4.qml @@ -0,0 +1,29 @@ +import Qt 4.6 + +Rectangle { + width: 400 + height: 400 + Rectangle { + id: theRect + objectName: "TheRect" + color: "red" + width: 50; height: 50 + x: 100; y: 100 + } + + states: State { + name: "moved" + PropertyChanges { + target: theRect + x: 200 + } + } + transitions: Transition { + NumberAnimation { target: theRect; matchProperties: "x" } + } + + MouseRegion { + anchors.fill: parent + onClicked: parent.state = "moved" + } +} diff --git a/tests/auto/declarative/qmlanimations/data/propertiesTransition5.qml b/tests/auto/declarative/qmlanimations/data/propertiesTransition5.qml new file mode 100644 index 0000000..565c519 --- /dev/null +++ b/tests/auto/declarative/qmlanimations/data/propertiesTransition5.qml @@ -0,0 +1,29 @@ +import Qt 4.6 + +Rectangle { + width: 400 + height: 400 + Rectangle { + id: theRect + objectName: "TheRect" + color: "red" + width: 50; height: 50 + x: 100; y: 100 + } + + states: State { + name: "moved" + PropertyChanges { + target: theRect + x: 200 + } + } + transitions: Transition { + NumberAnimation { matchTargets: theRect; property: "x" } + } + + MouseRegion { + anchors.fill: parent + onClicked: parent.state = "moved" + } +} diff --git a/tests/auto/declarative/qmlanimations/data/propertiesTransition6.qml b/tests/auto/declarative/qmlanimations/data/propertiesTransition6.qml new file mode 100644 index 0000000..b541dab --- /dev/null +++ b/tests/auto/declarative/qmlanimations/data/propertiesTransition6.qml @@ -0,0 +1,29 @@ +import Qt 4.6 + +Rectangle { + width: 400 + height: 400 + Rectangle { + id: theRect + objectName: "TheRect" + color: "red" + width: 50; height: 50 + x: 100; y: 100 + } + + states: State { + name: "moved" + PropertyChanges { + target: theRect + x: 200 + } + } + transitions: Transition { + NumberAnimation { matchTargets: theItem; matchProperties: "x" } + } + + MouseRegion { + anchors.fill: parent + onClicked: parent.state = "moved" + } +} diff --git a/tests/auto/declarative/qmlanimations/data/valuesource.qml b/tests/auto/declarative/qmlanimations/data/valuesource.qml new file mode 100644 index 0000000..c35063d --- /dev/null +++ b/tests/auto/declarative/qmlanimations/data/valuesource.qml @@ -0,0 +1,14 @@ +import Qt 4.6 + +Rectangle { + width: 400 + height: 400 + Rectangle { + id: rect + objectName: "MyRect" + color: "red" + width: 50; height: 50 + x: 100; y: 100 + x: NumberAnimation { id: anim; objectName: "MyAnim"; to: 200 } + } +} diff --git a/tests/auto/declarative/qmlanimations/data/valuesource2.qml b/tests/auto/declarative/qmlanimations/data/valuesource2.qml new file mode 100644 index 0000000..1a60542 --- /dev/null +++ b/tests/auto/declarative/qmlanimations/data/valuesource2.qml @@ -0,0 +1,14 @@ +import Qt 4.6 + +Rectangle { + width: 400 + height: 400 + Rectangle { + id: rect + objectName: "MyRect" + color: "red" + width: 50; height: 50 + x: 100; y: 100 + x: NumberAnimation { id: anim; objectName: "MyAnim"; running: false; to: 200 } + } +} diff --git a/tests/auto/declarative/qmlanimations/qmlanimations.pro b/tests/auto/declarative/qmlanimations/qmlanimations.pro new file mode 100644 index 0000000..447fb0f --- /dev/null +++ b/tests/auto/declarative/qmlanimations/qmlanimations.pro @@ -0,0 +1,6 @@ +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 new file mode 100644 index 0000000..17085af --- /dev/null +++ b/tests/auto/declarative/qmlanimations/tst_qmlanimations.cpp @@ -0,0 +1,611 @@ +/**************************************************************************** +** +** 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 +#include +#include +#include +#include +#include +#include + +class tst_animations : public QObject +{ + Q_OBJECT +public: + tst_animations() {} + +private slots: + 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(); +}; + +#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_animations::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_animations::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_animations::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_animations::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_animations::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_animations::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(50); + 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(50); + animation.stop(); + QVERIFY(rect.x() > x); +} + +void tst_animations::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_animations::badTypes() +{ + //don't crash + { + QmlView *view = new QmlView; + view->setUrl(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(c.create()); + QVERIFY(rect); + + rect->setState("state1"); + QTest::qWait(1000 + 50); + QmlGraphicsRectangle *myRect = rect->findChild("MyRect"); + QVERIFY(myRect); + QCOMPARE(myRect->x(),qreal(200)); + } +} + +void tst_animations::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-existant property \"border.colr\""; + QTest::ignoreMessage(QtWarningMsg, message); + QTest::ignoreMessage(QtWarningMsg, message); // why twice? + QmlGraphicsRectangle *rect = qobject_cast(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); + QTest::ignoreMessage(QtWarningMsg, message); // why twice? + rect = qobject_cast(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_animations::mixedTypes() +{ + //assumes border.width stats a real -- not real robust + { + QmlEngine engine; + QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/mixedtype1.qml")); + QmlGraphicsRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + rect->setState("state1"); + QTest::qWait(500); + QmlGraphicsRectangle *myRect = rect->findChild("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(c.create()); + QVERIFY(rect); + + rect->setState("state1"); + QTest::qWait(500); + QmlGraphicsRectangle *myRect = rect->findChild("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_animations::properties() +{ + const int waitDuration = 300; + { + QmlEngine engine; + QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/properties.qml")); + QmlGraphicsRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QmlGraphicsRectangle *myRect = rect->findChild("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(c.create()); + QVERIFY(rect); + + QmlGraphicsRectangle *myRect = rect->findChild("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(c.create()); + QVERIFY(rect); + + QmlGraphicsRectangle *myRect = rect->findChild("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(c.create()); + QVERIFY(rect); + + QmlGraphicsRectangle *myRect = rect->findChild("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(c.create()); + QVERIFY(rect); + + QmlGraphicsRectangle *myRect = rect->findChild("TheRect"); + QVERIFY(myRect); + QTest::qWait(waitDuration); + QEXPECT_FAIL("", "QTBUG-8072", Continue); + QTIMED_COMPARE(myRect->x(),qreal(100)); + QTIMED_COMPARE(myRect->y(),qreal(100)); + } +} + +void tst_animations::propertiesTransition() +{ + const int waitDuration = 300; + { + QmlEngine engine; + QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertiesTransition.qml")); + QmlGraphicsRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + rect->setState("moved"); + QmlGraphicsRectangle *myRect = rect->findChild("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(c.create()); + QVERIFY(rect); + + QmlGraphicsRectangle *myRect = rect->findChild("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(c.create()); + QVERIFY(rect); + + QmlGraphicsRectangle *myRect = rect->findChild("TheRect"); + QVERIFY(myRect); + QTest::ignoreMessage(QtWarningMsg, "QML NumberAnimation (" + QUrl::fromLocalFile(SRCDIR "/data/propertiesTransition4.qml").toString().toUtf8() + ":22:9) matchTargets/matchProperties/exclude and target/property are mutually exclusive."); + rect->setState("moved"); + QCOMPARE(myRect->x(),qreal(200)); + } + + { + QmlEngine engine; + QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertiesTransition4.qml")); + QmlGraphicsRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QmlGraphicsRectangle *myRect = rect->findChild("TheRect"); + QVERIFY(myRect); + QTest::ignoreMessage(QtWarningMsg, "QML NumberAnimation (" + QUrl::fromLocalFile(SRCDIR "/data/propertiesTransition5.qml").toString().toUtf8() + ":22:9) matchTargets/matchProperties/exclude and target/property are mutually exclusive."); + rect->setState("moved"); + QCOMPARE(myRect->x(),qreal(200)); + } + + { + QmlEngine engine; + QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertiesTransition5.qml")); + QmlGraphicsRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + //### should output warning at some point -- theItem doesn't exist + QmlGraphicsRectangle *myRect = rect->findChild("TheRect"); + QVERIFY(myRect); + rect->setState("moved"); + QCOMPARE(myRect->x(),qreal(200)); + } +} + +void tst_animations::easingStringConversion() +{ + QmlNumberAnimation *animation = new QmlNumberAnimation; + animation->setEasing("easeInOutQuad"); + QCOMPARE(animation->easing(),QLatin1String("easeInOutQuad")); + QCOMPARE(static_cast(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve(), QEasingCurve(QEasingCurve::InOutQuad)); + + animation->setEasing("OutQuad"); + QCOMPARE(static_cast(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve(), QEasingCurve(QEasingCurve::OutQuad)); + + animation->setEasing("easeOutBounce(amplitude: 5)"); + QCOMPARE(static_cast(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve().type(), QEasingCurve::OutBounce); + QCOMPARE(static_cast(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve().amplitude(), qreal(5)); + + animation->setEasing("easeOutElastic(amplitude: 5, period: 3)"); + QCOMPARE(static_cast(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve().type(), QEasingCurve::OutElastic); + QCOMPARE(static_cast(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve().amplitude(), qreal(5)); + QCOMPARE(static_cast(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve().period(), qreal(3)); + + animation->setEasing("easeInOutBack(overshoot: 2)"); + QCOMPARE(static_cast(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve().type(), QEasingCurve::InOutBack); + QCOMPARE(static_cast(((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(((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(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve().type(), QEasingCurve::Linear); + + QTest::ignoreMessage(QtWarningMsg, "QML NumberAnimation (unknown location) Unknown easing curve \"NonExistantEase\""); + animation->setEasing("NonExistantEase"); + QCOMPARE(static_cast(((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(((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(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve().type(), QEasingCurve::InOutElastic); + QVERIFY(static_cast(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve().amplitude() != qreal(5)); + + QTest::ignoreMessage(QtWarningMsg, "QML NumberAnimation (unknown location) Unknown easing parameter \"nonexistantproperty\""); + animation->setEasing("easeOutQuad(nonexistantproperty: 12)"); + QCOMPARE(static_cast(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve().type(), QEasingCurve::OutQuad); + + delete animation; +} + +void tst_animations::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_animations::attached() +{ + QmlEngine engine; + + QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/attached.qml")); + QTest::ignoreMessage(QtDebugMsg, "off"); + QTest::ignoreMessage(QtDebugMsg, "on"); + QmlGraphicsRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); +} + +void tst_animations::propertyValueSourceDefaultStart() +{ + { + QmlEngine engine; + + QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/valuesource.qml")); + + QmlGraphicsRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QmlAbstractAnimation *myAnim = rect->findChild("MyAnim"); + QVERIFY(myAnim); + QVERIFY(myAnim->isRunning()); + } + + { + QmlEngine engine; + + QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/valuesource2.qml")); + + QmlGraphicsRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QmlAbstractAnimation *myAnim = rect->findChild("MyAnim"); + QVERIFY(myAnim); + QVERIFY(myAnim->isRunning() == false); + } +} + +QTEST_MAIN(tst_animations) + +#include "tst_animations.moc" diff --git a/tests/auto/declarative/qmlbehaviors/data/binding.qml b/tests/auto/declarative/qmlbehaviors/data/binding.qml new file mode 100644 index 0000000..e0c3321 --- /dev/null +++ b/tests/auto/declarative/qmlbehaviors/data/binding.qml @@ -0,0 +1,26 @@ +import Qt 4.6 +Rectangle { + width: 400 + height: 400 + property real basex : 0 + property real movedx: 200 + Rectangle { + id: rect + objectName: "MyRect" + width: 100; height: 100; color: "green" + x: basex + x: Behavior { NumberAnimation { duration: 200; } } + } + MouseRegion { + id: clicker + anchors.fill: parent + } + states: State { + name: "moved" + when: clicker.pressed + PropertyChanges { + target: rect + x: movedx + } + } +} diff --git a/tests/auto/declarative/qmlbehaviors/data/color.qml b/tests/auto/declarative/qmlbehaviors/data/color.qml new file mode 100644 index 0000000..6598703 --- /dev/null +++ b/tests/auto/declarative/qmlbehaviors/data/color.qml @@ -0,0 +1,24 @@ +import Qt 4.6 +Rectangle { + width: 400 + height: 400 + Rectangle { + id: rect + objectName: "MyRect" + width: 100; height: 100; + color: "green" + color: Behavior { ColorAnimation { duration: 200; } } + } + MouseRegion { + id: clicker + anchors.fill: parent + } + states: State { + name: "red" + when: clicker.pressed + PropertyChanges { + target: rect + color: "red" + } + } +} diff --git a/tests/auto/declarative/qmlbehaviors/data/cpptrigger.qml b/tests/auto/declarative/qmlbehaviors/data/cpptrigger.qml new file mode 100644 index 0000000..ba507c4 --- /dev/null +++ b/tests/auto/declarative/qmlbehaviors/data/cpptrigger.qml @@ -0,0 +1,11 @@ +import Qt 4.6 +Rectangle { + width: 400 + height: 400 + Rectangle { + id: rect + objectName: "MyRect" + width: 100; height: 100; color: "green" + x: Behavior { NumberAnimation { duration: 200; } } + } +} diff --git a/tests/auto/declarative/qmlbehaviors/data/disabled.qml b/tests/auto/declarative/qmlbehaviors/data/disabled.qml new file mode 100644 index 0000000..e7b8d51 --- /dev/null +++ b/tests/auto/declarative/qmlbehaviors/data/disabled.qml @@ -0,0 +1,27 @@ +import Qt 4.6 +Rectangle { + width: 400 + height: 400 + Rectangle { + id: rect + objectName: "MyRect" + width: 100; height: 100; color: "green" + x: Behavior { + objectName: "MyBehavior"; + enabled: false + NumberAnimation { duration: 200; } + } + } + MouseRegion { + id: clicker + anchors.fill: parent + } + states: State { + name: "moved" + when: clicker.pressed + PropertyChanges { + target: rect + x: 200 + } + } +} diff --git a/tests/auto/declarative/qmlbehaviors/data/empty.qml b/tests/auto/declarative/qmlbehaviors/data/empty.qml new file mode 100644 index 0000000..412e26c --- /dev/null +++ b/tests/auto/declarative/qmlbehaviors/data/empty.qml @@ -0,0 +1,23 @@ +import Qt 4.6 +Rectangle { + width: 400 + height: 400 + Rectangle { + id: rect + objectName: "MyRect" + width: 100; height: 100; color: "green" + x: Behavior {} + } + MouseRegion { + id: clicker + anchors.fill: parent + } + states: State { + name: "moved" + when: clicker.pressed + PropertyChanges { + target: rect + x: 200 + } + } +} diff --git a/tests/auto/declarative/qmlbehaviors/data/groupProperty.qml b/tests/auto/declarative/qmlbehaviors/data/groupProperty.qml new file mode 100644 index 0000000..4f127c1 --- /dev/null +++ b/tests/auto/declarative/qmlbehaviors/data/groupProperty.qml @@ -0,0 +1,23 @@ +import Qt 4.6 +Rectangle { + width: 400 + height: 400 + Rectangle { + id: rect + objectName: "MyRect" + width: 100; height: 100; color: "green" + pos: Behavior { PropertyAnimation { duration: 200; } } + } + MouseRegion { + id: clicker + anchors.fill: parent + } + states: State { + name: "moved" + when: clicker.pressed + PropertyChanges { + target: rect + pos: Qt.point(200,0); + } + } +} diff --git a/tests/auto/declarative/qmlbehaviors/data/groupProperty2.qml b/tests/auto/declarative/qmlbehaviors/data/groupProperty2.qml new file mode 100644 index 0000000..19d70b6 --- /dev/null +++ b/tests/auto/declarative/qmlbehaviors/data/groupProperty2.qml @@ -0,0 +1,23 @@ +import Qt 4.6 +Rectangle { + width: 400 + height: 400 + Rectangle { + id: rect + objectName: "MyRect" + width: 100; height: 100; color: "green" + pos.x: Behavior { NumberAnimation { duration: 200; } } + } + MouseRegion { + id: clicker + anchors.fill: parent + } + states: State { + name: "moved" + when: clicker.pressed + PropertyChanges { + target: rect + pos.x: 200; + } + } +} diff --git a/tests/auto/declarative/qmlbehaviors/data/loop.qml b/tests/auto/declarative/qmlbehaviors/data/loop.qml new file mode 100644 index 0000000..5f2c057 --- /dev/null +++ b/tests/auto/declarative/qmlbehaviors/data/loop.qml @@ -0,0 +1,19 @@ +import Qt 4.6 +Rectangle { + width: 400 + height: 400 + Rectangle { + id: rect + objectName: "MyRect" + width: 100; height: 100; color: "green" + x: Behavior { NumberAnimation { duration: 200; } } + onXChanged: x = 100; + } + states: State { + name: "moved" + PropertyChanges { + target: rect + x: 200 + } + } +} diff --git a/tests/auto/declarative/qmlbehaviors/data/nonSelecting.qml b/tests/auto/declarative/qmlbehaviors/data/nonSelecting.qml new file mode 100644 index 0000000..ba36d93 --- /dev/null +++ b/tests/auto/declarative/qmlbehaviors/data/nonSelecting.qml @@ -0,0 +1,26 @@ +import Qt 4.6 +Rectangle { + width: 400 + height: 400 + Rectangle { + id: rect + objectName: "MyRect" + width: 100; height: 100; color: "green" + x: Behavior { + objectName: "MyBehavior"; + NumberAnimation { target: rect; property: "x"; duration: 200; } + } + } + MouseRegion { + id: clicker + anchors.fill: parent + } + states: State { + name: "moved" + when: clicker.pressed + PropertyChanges { + target: rect + x: 200 + } + } +} diff --git a/tests/auto/declarative/qmlbehaviors/data/nonSelecting2.qml b/tests/auto/declarative/qmlbehaviors/data/nonSelecting2.qml new file mode 100644 index 0000000..e9849eb --- /dev/null +++ b/tests/auto/declarative/qmlbehaviors/data/nonSelecting2.qml @@ -0,0 +1,26 @@ +import Qt 4.6 +Rectangle { + width: 400 + height: 400 + Rectangle { + id: rect + objectName: "MyRect" + width: 100; height: 100; color: "green" + x: Behavior { + objectName: "MyBehavior"; + NumberAnimation { matchTargets: rect; matchProperties: "y"; duration: 200; } + } + } + MouseRegion { + id: clicker + anchors.fill: parent + } + states: State { + name: "moved" + when: clicker.pressed + PropertyChanges { + target: rect + x: 200 + } + } +} diff --git a/tests/auto/declarative/qmlbehaviors/data/parent.qml b/tests/auto/declarative/qmlbehaviors/data/parent.qml new file mode 100644 index 0000000..4f4911b --- /dev/null +++ b/tests/auto/declarative/qmlbehaviors/data/parent.qml @@ -0,0 +1,28 @@ +import Qt 4.6 +Rectangle { + width: 400 + height: 400 + Rectangle { + id: rect + objectName: "MyRect" + width: 100; height: 100; color: "green" + parent: Behavior { + SequentialAnimation { + PauseAnimation { duration: 200 } + PropertyAction {} + } + } + } + Item { + id: newParent + objectName: "NewParent" + x: 100 + } + states: State { + name: "reparented" + PropertyChanges { + target: rect + parent: newParent + } + } +} diff --git a/tests/auto/declarative/qmlbehaviors/data/reassignedAnimation.qml b/tests/auto/declarative/qmlbehaviors/data/reassignedAnimation.qml new file mode 100644 index 0000000..693a595 --- /dev/null +++ b/tests/auto/declarative/qmlbehaviors/data/reassignedAnimation.qml @@ -0,0 +1,27 @@ +import Qt 4.6 +Rectangle { + width: 400 + height: 400 + Rectangle { + id: rect + objectName: "MyRect" + width: 100; height: 100; color: "green" + x: Behavior { + objectName: "MyBehavior" + NumberAnimation { duration: 200 } + NumberAnimation { duration: 1000 } + } + } + MouseRegion { + id: clicker + anchors.fill: parent + } + states: State { + name: "moved" + when: clicker.pressed + PropertyChanges { + target: rect + x: 200 + } + } +} diff --git a/tests/auto/declarative/qmlbehaviors/data/scripttrigger.qml b/tests/auto/declarative/qmlbehaviors/data/scripttrigger.qml new file mode 100644 index 0000000..4383a0b --- /dev/null +++ b/tests/auto/declarative/qmlbehaviors/data/scripttrigger.qml @@ -0,0 +1,16 @@ +import Qt 4.6 +Rectangle { + width: 400 + height: 400 + + onColorChanged: { + rect.x = 200 + } + + Rectangle { + id: rect + objectName: "MyRect" + width: 100; height: 100; color: "green" + x: Behavior { NumberAnimation { duration: 200; } } + } +} diff --git a/tests/auto/declarative/qmlbehaviors/data/simple.qml b/tests/auto/declarative/qmlbehaviors/data/simple.qml new file mode 100644 index 0000000..37c3915 --- /dev/null +++ b/tests/auto/declarative/qmlbehaviors/data/simple.qml @@ -0,0 +1,26 @@ +import Qt 4.6 +Rectangle { + width: 400 + height: 400 + Rectangle { + id: rect + objectName: "MyRect" + width: 100; height: 100; color: "green" + x: Behavior { + objectName: "MyBehavior"; + NumberAnimation { duration: 200; } + } + } + MouseRegion { + id: clicker + anchors.fill: parent + } + states: State { + name: "moved" + when: clicker.pressed + PropertyChanges { + target: rect + x: 200 + } + } +} diff --git a/tests/auto/declarative/qmlbehaviors/qmlbehaviors.pro b/tests/auto/declarative/qmlbehaviors/qmlbehaviors.pro new file mode 100644 index 0000000..1e685ee --- /dev/null +++ b/tests/auto/declarative/qmlbehaviors/qmlbehaviors.pro @@ -0,0 +1,6 @@ +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 new file mode 100644 index 0000000..fd84596 --- /dev/null +++ b/tests/auto/declarative/qmlbehaviors/tst_qmlbehaviors.cpp @@ -0,0 +1,281 @@ +/**************************************************************************** +** +** 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 +#include +#include +#include +#include +#include +#include + +class tst_behaviors : public QObject +{ + Q_OBJECT +public: + tst_behaviors() {} + +private slots: + void simpleBehavior(); + void scriptTriggered(); + void cppTriggered(); + void loop(); + void colorBehavior(); + void parentBehavior(); + void replaceBinding(); + //void transitionOverrides(); + void group(); + void emptyBehavior(); + void nonSelectingBehavior(); + void reassignedAnimation(); + void disabled(); +}; + +void tst_behaviors::simpleBehavior() +{ + QmlEngine engine; + QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/simple.qml")); + QmlGraphicsRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + QVERIFY(qobject_cast(rect->findChild("MyBehavior"))->animation()); + + rect->setState("moved"); + QTest::qWait(100); + qreal x = qobject_cast(rect->findChild("MyRect"))->x(); + QVERIFY(x > 0 && x < 200); //i.e. the behavior has been triggered +} + +void tst_behaviors::scriptTriggered() +{ + QmlEngine engine; + QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/scripttrigger.qml")); + QmlGraphicsRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + rect->setColor(QColor("red")); + QTest::qWait(100); + qreal x = qobject_cast(rect->findChild("MyRect"))->x(); + QVERIFY(x > 0 && x < 200); //i.e. the behavior has been triggered +} + +void tst_behaviors::cppTriggered() +{ + QmlEngine engine; + QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/cpptrigger.qml")); + QmlGraphicsRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QmlGraphicsRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); + QVERIFY(innerRect); + + innerRect->setProperty("x", 200); + QTest::qWait(100); + qreal x = innerRect->x(); + QVERIFY(x > 0 && x < 200); //i.e. the behavior has been triggered +} + +void tst_behaviors::loop() +{ + QmlEngine engine; + QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/loop.qml")); + QmlGraphicsRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + //don't crash + rect->setState("moved"); +} + +void tst_behaviors::colorBehavior() +{ + QmlEngine engine; + QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/color.qml")); + QmlGraphicsRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + rect->setState("red"); + QTest::qWait(100); + QColor color = qobject_cast(rect->findChild("MyRect"))->color(); + QVERIFY(color != QColor("red") && color != QColor("green")); //i.e. the behavior has been triggered +} + +void tst_behaviors::parentBehavior() +{ + QmlEngine engine; + QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/parent.qml")); + QmlGraphicsRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + rect->setState("reparented"); + QTest::qWait(100); + QmlGraphicsItem *newParent = rect->findChild("NewParent"); + QmlGraphicsItem *parent = rect->findChild("MyRect")->parentItem(); + QVERIFY(parent != newParent); + QTest::qWait(300); + parent = rect->findChild("MyRect")->parentItem(); + QVERIFY(parent == newParent); +} + +void tst_behaviors::replaceBinding() +{ + QmlEngine engine; + QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/binding.qml")); + QmlGraphicsRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + rect->setState("moved"); + QTest::qWait(100); + QmlGraphicsRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); + QVERIFY(innerRect); + qreal x = innerRect->x(); + QVERIFY(x > 0 && x < 200); //i.e. the behavior has been triggered + QTest::qWait(300); + QCOMPARE(innerRect->x(), (qreal)200); + rect->setProperty("basex", 10); + QCOMPARE(innerRect->x(), (qreal)200); + rect->setProperty("movedx", 210); + QTest::qWait(300); + QCOMPARE(innerRect->x(), (qreal)210); + + rect->setState(""); + QTest::qWait(100); + x = innerRect->x(); + QVERIFY(x > 10 && x < 210); //i.e. the behavior has been triggered + QTest::qWait(300); + QCOMPARE(innerRect->x(), (qreal)10); + rect->setProperty("movedx", 200); + QCOMPARE(innerRect->x(), (qreal)10); + rect->setProperty("basex", 20); + QTest::qWait(300); + QCOMPARE(innerRect->x(), (qreal)20); +} + +void tst_behaviors::group() +{ + { + QmlEngine engine; + QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/groupProperty.qml")); + QmlGraphicsRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + rect->setState("moved"); + QTest::qWait(100); + qreal x = qobject_cast(rect->findChild("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(c.create()); + QVERIFY(rect); + + rect->setState("moved"); + QTest::qWait(100); + qreal x = qobject_cast(rect->findChild("MyRect"))->x(); + QVERIFY(x > 0 && x < 200); //i.e. the behavior has been triggered + } +} + +void tst_behaviors::emptyBehavior() +{ + QmlEngine engine; + QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/empty.qml")); + QmlGraphicsRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + rect->setState("moved"); + qreal x = qobject_cast(rect->findChild("MyRect"))->x(); + QCOMPARE(x, qreal(200)); //should change immediately +} + +void tst_behaviors::nonSelectingBehavior() +{ + { + QmlEngine engine; + QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/nonSelecting.qml")); + QmlGraphicsRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + rect->setState("moved"); + qreal x = qobject_cast(rect->findChild("MyRect"))->x(); + QCOMPARE(x, qreal(200)); //should change immediately + } + + { + QmlEngine engine; + QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/nonSelecting2.qml")); + QmlGraphicsRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + rect->setState("moved"); + qreal x = qobject_cast(rect->findChild("MyRect"))->x(); + QCOMPARE(x, qreal(200)); //should change immediately + } +} + +void tst_behaviors::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) Can't change the animation assigned to a Behavior.").toUtf8().constData()); + QmlGraphicsRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + QCOMPARE(qobject_cast( + qobject_cast( + rect->findChild("MyBehavior"))->animation())->duration(), 200); +} + +void tst_behaviors::disabled() +{ + QmlEngine engine; + QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/disabled.qml")); + QmlGraphicsRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + QCOMPARE(rect->findChild("MyBehavior")->enabled(), false); + + rect->setState("moved"); + qreal x = qobject_cast(rect->findChild("MyRect"))->x(); + QCOMPARE(x, qreal(200)); //should change immediately + +} + +QTEST_MAIN(tst_behaviors) + +#include "tst_behaviors.moc" diff --git a/tests/auto/declarative/qmldatetimeformatter/qmldatetimeformatter.pro b/tests/auto/declarative/qmldatetimeformatter/qmldatetimeformatter.pro new file mode 100644 index 0000000..2b1947d --- /dev/null +++ b/tests/auto/declarative/qmldatetimeformatter/qmldatetimeformatter.pro @@ -0,0 +1,5 @@ +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 new file mode 100644 index 0000000..3302cfa --- /dev/null +++ b/tests/auto/declarative/qmldatetimeformatter/tst_qmldatetimeformatter.cpp @@ -0,0 +1,150 @@ +/**************************************************************************** +** +** 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 +#include +#include +#include +#include + +class tst_datetimeformatter : public QObject +{ + Q_OBJECT +public: + tst_datetimeformatter() {} + +private slots: + void date(); + void time(); + void dateTime(); +}; + +void tst_datetimeformatter::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(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_datetimeformatter::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(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_datetimeformatter::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(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_datetimeformatter) + +#include "tst_datetimeformatter.moc" diff --git a/tests/auto/declarative/qmlgraphicsanchors/data/anchors.qml b/tests/auto/declarative/qmlgraphicsanchors/data/anchors.qml new file mode 100644 index 0000000..b64d0b0 --- /dev/null +++ b/tests/auto/declarative/qmlgraphicsanchors/data/anchors.qml @@ -0,0 +1,162 @@ +import Qt 4.6 + +Rectangle { + color: "white" + width: 240 + height: 320 + Rectangle { id: masterRect; objectName: "masterRect"; x: 26; width: 96; height: 20; color: "red" } + Rectangle { + id: rect1; objectName: "rect1" + y: 20; width: 10; height: 10 + anchors.left: masterRect.left + } + Rectangle { + id: rect2; objectName: "rect2" + y: 20; width: 10; height: 10 + anchors.left: masterRect.right + } + Rectangle { + id: rect3; objectName: "rect3" + y: 20; width: 10; height: 10 + anchors.left: masterRect.horizontalCenter + } + Rectangle { + id: rect4; objectName: "rect4" + y: 30; width: 10; height: 10 + anchors.right: masterRect.left + } + Rectangle { + id: rect5; objectName: "rect5" + y: 30; width: 10; height: 10 + anchors.right: masterRect.right + } + Rectangle { + id: rect6; objectName: "rect6" + y: 30; width: 10; height: 10 + anchors.right: masterRect.horizontalCenter + } + Rectangle { + id: rect7; objectName: "rect7" + y: 50; width: 10; height: 10 + anchors.left: parent.left + } + Rectangle { + id: rect8; objectName: "rect8" + y: 50; width: 10; height: 10 + anchors.left: parent.right + } + Rectangle { + id: rect9; objectName: "rect9" + y: 50; width: 10; height: 10 + anchors.left: parent.horizontalCenter + } + Rectangle { + id: rect10; objectName: "rect10" + y: 60; width: 10; height: 10 + anchors.right: parent.left + } + Rectangle { + id: rect11; objectName: "rect11" + y: 60; width: 10; height: 10 + anchors.right: parent.right + } + Rectangle { + id: rect12; objectName: "rect12" + y: 60; width: 10; height: 10 + anchors.right: parent.horizontalCenter + } + Rectangle { + id: rect13; objectName: "rect13" + x: 200; width: 10; height: 10 + anchors.top: masterRect.bottom + } + Rectangle { + id: rect14; objectName: "rect14" + width: 10; height: 10; color: "steelblue" + anchors.verticalCenter: parent.verticalCenter + } + Rectangle { + id: rect15; objectName: "rect15" + y: 200; height: 10 + anchors.left: masterRect.left + anchors.right: masterRect.right + } + Rectangle { + id: rect16; objectName: "rect16" + y: 220; height: 10 + anchors.left: masterRect.left + anchors.horizontalCenter: masterRect.right + } + Rectangle { + id: rect17; objectName: "rect17" + y: 240; height: 10 + anchors.right: masterRect.right + anchors.horizontalCenter: masterRect.left + } + Rectangle { + id: rect18; objectName: "rect18" + x: 180; width: 10 + anchors.top: masterRect.bottom + anchors.bottom: rect12.top + } + Rectangle { + id: rect19; objectName: "rect19" + y: 70; width: 10; height: 10 + anchors.horizontalCenter: parent.horizontalCenter + } + Rectangle { + id: rect20; objectName: "rect20" + y: 70; width: 10; height: 10 + anchors.horizontalCenter: parent.right + } + Rectangle { + id: rect21; objectName: "rect21" + y: 70; width: 10; height: 10 + anchors.horizontalCenter: parent.left + } + Rectangle { + id: rect22; objectName: "rect22" + width: 10; height: 10 + anchors.centerIn: masterRect + } + Rectangle { + id: rect23; objectName: "rect23" + anchors.left: masterRect.left + anchors.leftMargin: 5 + anchors.right: masterRect.right + anchors.rightMargin: 5 + anchors.top: masterRect.top + anchors.topMargin: 5 + anchors.bottom: masterRect.bottom + anchors.bottomMargin: 5 + } + Rectangle { + id: rect24; objectName: "rect24" + width: 10; height: 10 + anchors.horizontalCenter: masterRect.left + anchors.horizontalCenterOffset: width/2 + } + Rectangle { + id: rect25; objectName: "rect25" + width: 10; height: 10 + anchors.verticalCenter: rect12.top + anchors.verticalCenterOffset: height/2 + } + Rectangle { + id: rect26; objectName: "rect26" + width: 10; height: 10 + anchors.baseline: masterRect.top + anchors.baselineOffset: height/2 + } + Text { + id: text1; objectName: "text1" + y: 200; + text: "Hello" + } + Text { + id: text2; objectName: "text2" + anchors.baseline: text1.baseline + anchors.left: text1.right + text: "World" + } +} diff --git a/tests/auto/declarative/qmlgraphicsanchors/data/centerin.qml b/tests/auto/declarative/qmlgraphicsanchors/data/centerin.qml new file mode 100644 index 0000000..09b97f6 --- /dev/null +++ b/tests/auto/declarative/qmlgraphicsanchors/data/centerin.qml @@ -0,0 +1,12 @@ +import Qt 4.6 + +Rectangle { + width: 200; height: 200 + Rectangle { + objectName: "centered" + width: 50; height: 50; color: "blue" + anchors.centerIn: parent; + anchors.verticalCenterOffset: 30 + anchors.horizontalCenterOffset: 10 + } +} diff --git a/tests/auto/declarative/qmlgraphicsanchors/data/crash1.qml b/tests/auto/declarative/qmlgraphicsanchors/data/crash1.qml new file mode 100644 index 0000000..fd9dc55 --- /dev/null +++ b/tests/auto/declarative/qmlgraphicsanchors/data/crash1.qml @@ -0,0 +1,11 @@ +import Qt 4.6 + +Column { + Text { + text: "foo" + anchors.fill: parent + } + Text { + text: "bar" + } +} diff --git a/tests/auto/declarative/qmlgraphicsanchors/data/fill.qml b/tests/auto/declarative/qmlgraphicsanchors/data/fill.qml new file mode 100644 index 0000000..902465c --- /dev/null +++ b/tests/auto/declarative/qmlgraphicsanchors/data/fill.qml @@ -0,0 +1,14 @@ +import Qt 4.6 + +Rectangle { + width: 200; height: 200 + Rectangle { + objectName: "filler" + width: 50; height: 50; color: "blue" + anchors.fill: parent; + anchors.leftMargin: 10; + anchors.rightMargin: 20; + anchors.topMargin: 30; + anchors.bottomMargin: 40; + } +} diff --git a/tests/auto/declarative/qmlgraphicsanchors/data/loop1.qml b/tests/auto/declarative/qmlgraphicsanchors/data/loop1.qml new file mode 100644 index 0000000..a266612 --- /dev/null +++ b/tests/auto/declarative/qmlgraphicsanchors/data/loop1.qml @@ -0,0 +1,8 @@ +import Qt 4.6 + +Rectangle { + id: rect + width: 120; height: 200; color: "white" + Text { id: text1; anchors.right: text2.right; text: "Hello" } + Text { id: text2; anchors.right: text1.right; anchors.rightMargin: 10; text: "World" } +} diff --git a/tests/auto/declarative/qmlgraphicsanchors/data/loop2.qml b/tests/auto/declarative/qmlgraphicsanchors/data/loop2.qml new file mode 100644 index 0000000..acb57cd --- /dev/null +++ b/tests/auto/declarative/qmlgraphicsanchors/data/loop2.qml @@ -0,0 +1,20 @@ +import Qt 4.6 + +Rectangle { + id: container; + width: 600; + height: 600; + + Image { + id: image1 + source: "http://labs.trolltech.com/blogs/wp-content/uploads/2009/03/3311388091_ac2a257feb.jpg" + anchors.right: image2.left + } + + Image { + id: image2 + source: "http://labs.trolltech.com/blogs/wp-content/uploads/2009/03/oslo_groupphoto.jpg" + anchors.left: image1.right + anchors.leftMargin: 20 + } +} diff --git a/tests/auto/declarative/qmlgraphicsanchors/data/margins.qml b/tests/auto/declarative/qmlgraphicsanchors/data/margins.qml new file mode 100644 index 0000000..4a29e77 --- /dev/null +++ b/tests/auto/declarative/qmlgraphicsanchors/data/margins.qml @@ -0,0 +1,13 @@ +import Qt 4.6 + +Rectangle { + width: 200; height: 200 + Rectangle { + objectName: "filler" + width: 50; height: 50; color: "blue" + anchors.fill: parent; + anchors.margins: 10 + anchors.leftMargin: 5 + anchors.topMargin: 6 + } +} diff --git a/tests/auto/declarative/qmlgraphicsanchors/qmlgraphicsanchors.pro b/tests/auto/declarative/qmlgraphicsanchors/qmlgraphicsanchors.pro new file mode 100644 index 0000000..755de3f --- /dev/null +++ b/tests/auto/declarative/qmlgraphicsanchors/qmlgraphicsanchors.pro @@ -0,0 +1,6 @@ +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 new file mode 100644 index 0000000..4cbfc94 --- /dev/null +++ b/tests/auto/declarative/qmlgraphicsanchors/tst_qmlgraphicsanchors.cpp @@ -0,0 +1,459 @@ +/**************************************************************************** +** +** 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 +#include +#include +#include +#include +#include +#include +#include + +Q_DECLARE_METATYPE(QmlGraphicsAnchors::UsedAnchor) +Q_DECLARE_METATYPE(QmlGraphicsAnchorLine::AnchorLine) + + +class tst_anchors : public QObject +{ + Q_OBJECT +public: + tst_anchors() {} + + template + T *findItem(QmlGraphicsItem *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 +T *tst_anchors::findItem(QmlGraphicsItem *parent, const QString &objectName) +{ + const QMetaObject &mo = T::staticMetaObject; + QList children = parent->childItems(); + for (int i = 0; i < children.count(); ++i) { + QmlGraphicsItem *item = qobject_cast(children.at(i)->toGraphicsObject()); + if (item) { + if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) { + return static_cast(item); + } + item = findItem(item, objectName); + if (item) + return static_cast(item); + } + } + + return 0; +} + +void tst_anchors::basicAnchors() +{ + QmlView *view = new QmlView; + view->setUrl(QUrl::fromLocalFile(SRCDIR "/data/anchors.qml")); + + view->execute(); + qApp->processEvents(); + + //sibling horizontal + QCOMPARE(findItem(view->root(), QLatin1String("rect1"))->x(), 26.0); + QCOMPARE(findItem(view->root(), QLatin1String("rect2"))->x(), 122.0); + QCOMPARE(findItem(view->root(), QLatin1String("rect3"))->x(), 74.0); + QCOMPARE(findItem(view->root(), QLatin1String("rect4"))->x(), 16.0); + QCOMPARE(findItem(view->root(), QLatin1String("rect5"))->x(), 112.0); + QCOMPARE(findItem(view->root(), QLatin1String("rect6"))->x(), 64.0); + + //parent horizontal + QCOMPARE(findItem(view->root(), QLatin1String("rect7"))->x(), 0.0); + QCOMPARE(findItem(view->root(), QLatin1String("rect8"))->x(), 240.0); + QCOMPARE(findItem(view->root(), QLatin1String("rect9"))->x(), 120.0); + QCOMPARE(findItem(view->root(), QLatin1String("rect10"))->x(), -10.0); + QCOMPARE(findItem(view->root(), QLatin1String("rect11"))->x(), 230.0); + QCOMPARE(findItem(view->root(), QLatin1String("rect12"))->x(), 110.0); + + //vertical + QCOMPARE(findItem(view->root(), QLatin1String("rect13"))->y(), 20.0); + QCOMPARE(findItem(view->root(), QLatin1String("rect14"))->y(), 155.0); + + //stretch + QCOMPARE(findItem(view->root(), QLatin1String("rect15"))->x(), 26.0); + QCOMPARE(findItem(view->root(), QLatin1String("rect15"))->width(), 96.0); + QCOMPARE(findItem(view->root(), QLatin1String("rect16"))->x(), 26.0); + QCOMPARE(findItem(view->root(), QLatin1String("rect16"))->width(), 192.0); + QCOMPARE(findItem(view->root(), QLatin1String("rect17"))->x(), -70.0); + QCOMPARE(findItem(view->root(), QLatin1String("rect17"))->width(), 192.0); + + //vertical stretch + QCOMPARE(findItem(view->root(), QLatin1String("rect18"))->y(), 20.0); + QCOMPARE(findItem(view->root(), QLatin1String("rect18"))->height(), 40.0); + + //more parent horizontal + QCOMPARE(findItem(view->root(), QLatin1String("rect19"))->x(), 115.0); + QCOMPARE(findItem(view->root(), QLatin1String("rect20"))->x(), 235.0); + QCOMPARE(findItem(view->root(), QLatin1String("rect21"))->x(), -5.0); + + //centerIn + QCOMPARE(findItem(view->root(), QLatin1String("rect22"))->x(), 69.0); + QCOMPARE(findItem(view->root(), QLatin1String("rect22"))->y(), 5.0); + + //margins + QCOMPARE(findItem(view->root(), QLatin1String("rect23"))->x(), 31.0); + QCOMPARE(findItem(view->root(), QLatin1String("rect23"))->y(), 5.0); + QCOMPARE(findItem(view->root(), QLatin1String("rect23"))->width(), 86.0); + QCOMPARE(findItem(view->root(), QLatin1String("rect23"))->height(), 10.0); + + // offsets + QCOMPARE(findItem(view->root(), QLatin1String("rect24"))->x(), 26.0); + QCOMPARE(findItem(view->root(), QLatin1String("rect25"))->y(), 60.0); + QCOMPARE(findItem(view->root(), QLatin1String("rect26"))->y(), 5.0); + + //baseline + QmlGraphicsText *text1 = findItem(view->root(), QLatin1String("text1")); + QmlGraphicsText *text2 = findItem(view->root(), QLatin1String("text2")); + QCOMPARE(text1->y(), text2->y()); + + delete view; +} + +// mostly testing that we don't crash +void tst_anchors::loops() +{ + { + QmlView *view = new QmlView; + + view->setUrl(QUrl::fromLocalFile(SRCDIR "/data/loop1.qml")); + + QString expect = "QML Text (" + view->url().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->setUrl(QUrl::fromLocalFile(SRCDIR "/data/loop2.qml")); + + QString expect = "QML Image (" + view->url().toString() + ":8:3" + ") Possible anchor loop detected on horizontal anchor."; + QTest::ignoreMessage(QtWarningMsg, expect.toLatin1()); + view->execute(); + qApp->processEvents(); + + delete view; + } +} + +void tst_anchors::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_anchors::illegalSets_data() +{ + QTest::addColumn("qml"); + QTest::addColumn("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) Can't 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) Can't 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) Can't 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) Can't 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) Can't 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 can't 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) Can't 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) Can't 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) Can't 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) Can't 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) Can't anchor to an item that isn't a parent or sibling."; +} + +void tst_anchors::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_anchors::reset_data() +{ + QTest::addColumn("side"); + QTest::addColumn("anchorLine"); + QTest::addColumn("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_anchors::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_anchors::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) Can't anchor to a null item."); + QVERIFY(p.write(item->anchors(), qVariantFromValue(anchor))); + + delete item; +} + +void tst_anchors::nullItem_data() +{ + QTest::addColumn("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_anchors::crash1() +{ + QmlView *view = new QmlView; + + view->setUrl(QUrl::fromLocalFile(SRCDIR "/data/crash1.qml")); + + QString expect = "QML Text (" + view->url().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_anchors::fill() +{ + QmlView *view = new QmlView; + + view->setUrl(QUrl::fromLocalFile(SRCDIR "/data/fill.qml")); + + view->execute(); + qApp->processEvents(); + QmlGraphicsRectangle* rect = findItem(view->root(), 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_anchors::centerIn() +{ + QmlView *view = new QmlView; + + view->setUrl(QUrl::fromLocalFile(SRCDIR "/data/centerin.qml")); + + view->execute(); + qApp->processEvents(); + QmlGraphicsRectangle* rect = findItem(view->root(), 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_anchors::margins() +{ + QmlView *view = new QmlView; + + view->setUrl(QUrl::fromLocalFile(SRCDIR "/data/margins.qml")); + + view->execute(); + qApp->processEvents(); + QmlGraphicsRectangle* rect = findItem(view->root(), 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_anchors) + +#include "tst_anchors.moc" diff --git a/tests/auto/declarative/qmlgraphicsanimatedimage/data/colors.gif b/tests/auto/declarative/qmlgraphicsanimatedimage/data/colors.gif new file mode 100644 index 0000000..1270bfa Binary files /dev/null and b/tests/auto/declarative/qmlgraphicsanimatedimage/data/colors.gif differ diff --git a/tests/auto/declarative/qmlgraphicsanimatedimage/data/colors.qml b/tests/auto/declarative/qmlgraphicsanimatedimage/data/colors.qml new file mode 100644 index 0000000..5bada34 --- /dev/null +++ b/tests/auto/declarative/qmlgraphicsanimatedimage/data/colors.qml @@ -0,0 +1,5 @@ +import Qt 4.6 + +AnimatedImage { + source: "colors.gif" +} diff --git a/tests/auto/declarative/qmlgraphicsanimatedimage/data/stickman.gif b/tests/auto/declarative/qmlgraphicsanimatedimage/data/stickman.gif new file mode 100644 index 0000000..7c4cd18 Binary files /dev/null and b/tests/auto/declarative/qmlgraphicsanimatedimage/data/stickman.gif differ diff --git a/tests/auto/declarative/qmlgraphicsanimatedimage/data/stickman.qml b/tests/auto/declarative/qmlgraphicsanimatedimage/data/stickman.qml new file mode 100644 index 0000000..a70db5d --- /dev/null +++ b/tests/auto/declarative/qmlgraphicsanimatedimage/data/stickman.qml @@ -0,0 +1,5 @@ +import Qt 4.6 + +AnimatedImage { + source: "stickman.gif" +} diff --git a/tests/auto/declarative/qmlgraphicsanimatedimage/data/stickmanpause.qml b/tests/auto/declarative/qmlgraphicsanimatedimage/data/stickmanpause.qml new file mode 100644 index 0000000..7ab17d4 --- /dev/null +++ b/tests/auto/declarative/qmlgraphicsanimatedimage/data/stickmanpause.qml @@ -0,0 +1,7 @@ +import Qt 4.6 + +AnimatedImage { + source: "stickman.gif" + paused: true + currentFrame: 2 +} diff --git a/tests/auto/declarative/qmlgraphicsanimatedimage/data/stickmanstopped.qml b/tests/auto/declarative/qmlgraphicsanimatedimage/data/stickmanstopped.qml new file mode 100644 index 0000000..53b0c3a --- /dev/null +++ b/tests/auto/declarative/qmlgraphicsanimatedimage/data/stickmanstopped.qml @@ -0,0 +1,6 @@ +import Qt 4.6 + +AnimatedImage { + source: "stickman.gif" + playing: false +} diff --git a/tests/auto/declarative/qmlgraphicsanimatedimage/qmlgraphicsanimatedimage.pro b/tests/auto/declarative/qmlgraphicsanimatedimage/qmlgraphicsanimatedimage.pro new file mode 100644 index 0000000..877dfab --- /dev/null +++ b/tests/auto/declarative/qmlgraphicsanimatedimage/qmlgraphicsanimatedimage.pro @@ -0,0 +1,7 @@ +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 new file mode 100644 index 0000000..ee072c8 --- /dev/null +++ b/tests/auto/declarative/qmlgraphicsanimatedimage/tst_qmlgraphicsanimatedimage.cpp @@ -0,0 +1,191 @@ +/**************************************************************************** +** +** 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 +#include +#include +#include +#include +#include +#include + +#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_animatedimage : public QObject +{ + Q_OBJECT +public: + tst_animatedimage() {} + +private slots: + void play(); + void pause(); + void stopped(); + void setFrame(); + void frameCount(); + void remote(); + void remote_data(); + void invalidSource(); +}; + +void tst_animatedimage::play() +{ + QmlEngine engine; + QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/stickman.qml")); + QmlGraphicsAnimatedImage *anim = qobject_cast(component.create()); + QVERIFY(anim); + QVERIFY(anim->isPlaying()); + + delete anim; +} + +void tst_animatedimage::pause() +{ + QmlEngine engine; + QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/stickmanpause.qml")); + QmlGraphicsAnimatedImage *anim = qobject_cast(component.create()); + QVERIFY(anim); + QVERIFY(anim->isPlaying()); + QVERIFY(anim->isPaused()); + + delete anim; +} + +void tst_animatedimage::stopped() +{ + QmlEngine engine; + QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/stickmanstopped.qml")); + QmlGraphicsAnimatedImage *anim = qobject_cast(component.create()); + QVERIFY(anim); + QVERIFY(!anim->isPlaying()); + QCOMPARE(anim->currentFrame(), 0); + + delete anim; +} + +void tst_animatedimage::setFrame() +{ + QmlEngine engine; + QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/stickmanpause.qml")); + QmlGraphicsAnimatedImage *anim = qobject_cast(component.create()); + QVERIFY(anim); + QVERIFY(anim->isPlaying()); + QCOMPARE(anim->currentFrame(), 2); + + delete anim; +} + +void tst_animatedimage::frameCount() +{ + QmlEngine engine; + QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/colors.qml")); + QmlGraphicsAnimatedImage *anim = qobject_cast(component.create()); + QVERIFY(anim); + QVERIFY(anim->isPlaying()); + QCOMPARE(anim->frameCount(), 3); + + delete anim; +} + +void tst_animatedimage::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(component.create()); + QVERIFY(anim); + + TRY_WAIT(anim->isPlaying()); + if (paused) { + TRY_WAIT(anim->isPaused()); + QCOMPARE(anim->currentFrame(), 2); + } + + delete anim; +} + +void tst_animatedimage::remote_data() +{ + QTest::addColumn("fileName"); + QTest::addColumn("paused"); + + QTest::newRow("playing") << "stickman.qml" << false; + QTest::newRow("paused") << "stickmanpause.qml" << true; +} + +void tst_animatedimage::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(component.create()); + QVERIFY(anim); + + QVERIFY(!anim->isPlaying()); + QVERIFY(!anim->isPaused()); + QCOMPARE(anim->currentFrame(), 0); + QCOMPARE(anim->frameCount(), 0); +} + +QTEST_MAIN(tst_animatedimage) + +#include "tst_animatedimage.moc" diff --git a/tests/auto/declarative/qmlnumberformatter/qmlnumberformatter.pro b/tests/auto/declarative/qmlnumberformatter/qmlnumberformatter.pro new file mode 100644 index 0000000..8113278 --- /dev/null +++ b/tests/auto/declarative/qmlnumberformatter/qmlnumberformatter.pro @@ -0,0 +1,5 @@ +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 new file mode 100644 index 0000000..b00e08a --- /dev/null +++ b/tests/auto/declarative/qmlnumberformatter/tst_qmlnumberformatter.cpp @@ -0,0 +1,222 @@ +/**************************************************************************** +** +** 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 +#include +#include +#include +#include +#include + +class tst_numberformat : public QObject +{ + Q_OBJECT +public: + tst_numberformat(); + + void init() {} + void initTestCase() {} + + void cleanup() {} + void cleanupTestCase() {} + +private slots: + void text_data(); + void text(); + +private: + QStringList strings; + QStringList formats; + QStringList texts; +}; + +tst_numberformat::tst_numberformat() +{ + 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_numberformat::text_data() +{ + QTest::addColumn("string"); + QTest::addColumn("format"); + QTest::addColumn("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_numberformat::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(formatterComponent.create()); + QVERIFY(formatter != 0); + + QCOMPARE(formatter->format(), format); + QCOMPARE(formatter->text(), text); + + delete formatter; +} + +QTEST_MAIN(tst_numberformat) + +#include "tst_numberformatter.moc" diff --git a/tests/auto/declarative/qmlstates/data/ExtendedRectangle.qml b/tests/auto/declarative/qmlstates/data/ExtendedRectangle.qml new file mode 100644 index 0000000..8d64663 --- /dev/null +++ b/tests/auto/declarative/qmlstates/data/ExtendedRectangle.qml @@ -0,0 +1,19 @@ +import Qt 4.6 +Rectangle { + id: extendedRect + objectName: "extendedRect" + property color extendedColor: "orange" + + width: 100; height: 100 + color: "red" + states: State { + name: "green" + PropertyChanges { + target: rect + onDidSomething: { + extendedRect.color = "green" + extendedColor = "green" + } + } + } +} diff --git a/tests/auto/declarative/qmlstates/data/anchorChanges.qml b/tests/auto/declarative/qmlstates/data/anchorChanges.qml new file mode 100644 index 0000000..7dce889 --- /dev/null +++ b/tests/auto/declarative/qmlstates/data/anchorChanges.qml @@ -0,0 +1,23 @@ +import Qt 4.6 + +Rectangle { + id: container + width: 200; height: 200 + Rectangle { + id: myRect + objectName: "MyRect" + width: 50; height: 50 + color: "green"; + anchors.left: parent.left + anchors.leftMargin: 5 + } + states: State { + name: "right" + AnchorChanges { + id: ancCh + target: myRect; + reset: "left" + right: container.right + } + } +} diff --git a/tests/auto/declarative/qmlstates/data/anchorChanges2.qml b/tests/auto/declarative/qmlstates/data/anchorChanges2.qml new file mode 100644 index 0000000..545345e --- /dev/null +++ b/tests/auto/declarative/qmlstates/data/anchorChanges2.qml @@ -0,0 +1,21 @@ +import Qt 4.6 + +Rectangle { + width: 200; height: 200 + Rectangle { + id: myRect + objectName: "MyRect" + width: 50; height: 50 + color: "green"; + anchors.left: parent.left + anchors.leftMargin: 5 + } + states: State { + name: "right" + AnchorChanges { + target: myRect; + reset: "left" + right: parent.right + } + } +} diff --git a/tests/auto/declarative/qmlstates/data/anchorChanges3.qml b/tests/auto/declarative/qmlstates/data/anchorChanges3.qml new file mode 100644 index 0000000..9d5b317 --- /dev/null +++ b/tests/auto/declarative/qmlstates/data/anchorChanges3.qml @@ -0,0 +1,29 @@ +import Qt 4.6 + +Rectangle { + id: container + width: 200; height: 200 + Rectangle { + id: myRect + objectName: "MyRect" + color: "green"; + anchors.left: parent.left + anchors.right: rightGuideline.left + anchors.top: topGuideline.top + anchors.bottom: container.bottom + } + Item { objectName: "LeftGuideline"; id: leftGuideline; x: 10 } + Item { id: rightGuideline; x: 150 } + Item { id: topGuideline; y: 10 } + Item { objectName: "BottomGuideline"; id: bottomGuideline; y: 150 } + states: State { + name: "reanchored" + AnchorChanges { + target: myRect; + left: leftGuideline.left + right: container.right + top: container.top + bottom: bottomGuideline.bottom + } + } +} diff --git a/tests/auto/declarative/qmlstates/data/anchorChanges4.qml b/tests/auto/declarative/qmlstates/data/anchorChanges4.qml new file mode 100644 index 0000000..f128989 --- /dev/null +++ b/tests/auto/declarative/qmlstates/data/anchorChanges4.qml @@ -0,0 +1,22 @@ +import Qt 4.6 + +Rectangle { + width: 200; height: 200 + Rectangle { + id: myRect + objectName: "MyRect" + color: "green"; + anchors.horizontalCenter: parent.horizontalCenter + anchors.verticalCenter: parent.verticalCenter + } + Item { objectName: "LeftGuideline"; id: leftGuideline; x: 10 } + Item { objectName: "BottomGuideline"; id: bottomGuideline; y: 150 } + states: State { + name: "reanchored" + AnchorChanges { + target: myRect; + horizontalCenter: bottomGuideline.horizontalCenter + verticalCenter: leftGuideline.verticalCenter + } + } +} diff --git a/tests/auto/declarative/qmlstates/data/anchorChanges5.qml b/tests/auto/declarative/qmlstates/data/anchorChanges5.qml new file mode 100644 index 0000000..4e6d34b --- /dev/null +++ b/tests/auto/declarative/qmlstates/data/anchorChanges5.qml @@ -0,0 +1,22 @@ +import Qt 4.6 + +Rectangle { + width: 200; height: 200 + Rectangle { + id: myRect + objectName: "MyRect" + color: "green"; + anchors.horizontalCenter: parent.horizontalCenter + anchors.baseline: parent.baseline + } + Item { objectName: "LeftGuideline"; id: leftGuideline; x: 10 } + Item { objectName: "BottomGuideline"; id: bottomGuideline; y: 150 } + states: State { + name: "reanchored" + AnchorChanges { + target: myRect; + horizontalCenter: bottomGuideline.horizontalCenter + baseline: leftGuideline.baseline + } + } +} diff --git a/tests/auto/declarative/qmlstates/data/autoStateAtStartupRestoreBug.qml b/tests/auto/declarative/qmlstates/data/autoStateAtStartupRestoreBug.qml new file mode 100644 index 0000000..693a5c5 --- /dev/null +++ b/tests/auto/declarative/qmlstates/data/autoStateAtStartupRestoreBug.qml @@ -0,0 +1,18 @@ +import Qt 4.6 + +Item { + id: root + property int input: 1 + property int test: 9 + + states: [ + State { + name: "portrait" + when: root.input == 1 + PropertyChanges { + target: root + test: 3 + } + } + ] +} diff --git a/tests/auto/declarative/qmlstates/data/basicBinding.qml b/tests/auto/declarative/qmlstates/data/basicBinding.qml new file mode 100644 index 0000000..6528113 --- /dev/null +++ b/tests/auto/declarative/qmlstates/data/basicBinding.qml @@ -0,0 +1,12 @@ +import Qt 4.6 +Rectangle { + id: myRectangle + + property color sourceColor: "blue" + width: 100; height: 100 + color: "red" + states: State { + name: "blue" + PropertyChanges { target: myRectangle; color: sourceColor } + } +} diff --git a/tests/auto/declarative/qmlstates/data/basicBinding2.qml b/tests/auto/declarative/qmlstates/data/basicBinding2.qml new file mode 100644 index 0000000..2e7b4cf --- /dev/null +++ b/tests/auto/declarative/qmlstates/data/basicBinding2.qml @@ -0,0 +1,12 @@ +import Qt 4.6 +Rectangle { + id: myRectangle + + property color sourceColor: "red" + width: 100; height: 100 + color: sourceColor + states: State { + name: "blue" + PropertyChanges { target: myRectangle; color: "blue" } + } +} diff --git a/tests/auto/declarative/qmlstates/data/basicBinding3.qml b/tests/auto/declarative/qmlstates/data/basicBinding3.qml new file mode 100644 index 0000000..a3c47d9 --- /dev/null +++ b/tests/auto/declarative/qmlstates/data/basicBinding3.qml @@ -0,0 +1,13 @@ +import Qt 4.6 +Rectangle { + id: myRectangle + + property color sourceColor: "red" + property color sourceColor2: "blue" + width: 100; height: 100 + color: sourceColor + states: State { + name: "blue" + PropertyChanges { target: myRectangle; color: sourceColor2 } + } +} diff --git a/tests/auto/declarative/qmlstates/data/basicBinding4.qml b/tests/auto/declarative/qmlstates/data/basicBinding4.qml new file mode 100644 index 0000000..1f52d0e --- /dev/null +++ b/tests/auto/declarative/qmlstates/data/basicBinding4.qml @@ -0,0 +1,17 @@ +import Qt 4.6 +Rectangle { + id: myRectangle + + property color sourceColor: "blue" + width: 100; height: 100 + color: "red" + states: [ + State { + name: "blue" + PropertyChanges { target: myRectangle; color: sourceColor } + }, + State { + name: "green" + PropertyChanges { target: myRectangle; color: "green" } + }] +} diff --git a/tests/auto/declarative/qmlstates/data/basicChanges.qml b/tests/auto/declarative/qmlstates/data/basicChanges.qml new file mode 100644 index 0000000..88ea256 --- /dev/null +++ b/tests/auto/declarative/qmlstates/data/basicChanges.qml @@ -0,0 +1,10 @@ +import Qt 4.6 +Rectangle { + id: myRectangle + width: 100; height: 100 + color: "red" + states: State { + name: "blue" + PropertyChanges { target: myRectangle; color: "blue" } + } +} diff --git a/tests/auto/declarative/qmlstates/data/basicChanges2.qml b/tests/auto/declarative/qmlstates/data/basicChanges2.qml new file mode 100644 index 0000000..4dd293f --- /dev/null +++ b/tests/auto/declarative/qmlstates/data/basicChanges2.qml @@ -0,0 +1,15 @@ +import Qt 4.6 +Rectangle { + id: myRectangle + width: 100; height: 100 + color: "red" + states: [ + State { + name: "blue" + PropertyChanges { target: myRectangle; color: "blue" } + }, + State { + name: "green" + PropertyChanges { target: myRectangle; color: "green" } + }] +} diff --git a/tests/auto/declarative/qmlstates/data/basicChanges3.qml b/tests/auto/declarative/qmlstates/data/basicChanges3.qml new file mode 100644 index 0000000..62ab1d5 --- /dev/null +++ b/tests/auto/declarative/qmlstates/data/basicChanges3.qml @@ -0,0 +1,15 @@ +import Qt 4.6 +Rectangle { + id: myRectangle + width: 100; height: 100 + color: "red" + states: [ + State { + name: "blue" + PropertyChanges { target: myRectangle; color: "blue" } + }, + State { + name: "bordered" + PropertyChanges { target: myRectangle; border.width: 2 } + }] +} diff --git a/tests/auto/declarative/qmlstates/data/basicExtension.qml b/tests/auto/declarative/qmlstates/data/basicExtension.qml new file mode 100644 index 0000000..1836f8a --- /dev/null +++ b/tests/auto/declarative/qmlstates/data/basicExtension.qml @@ -0,0 +1,16 @@ +import Qt 4.6 +Rectangle { + id: myRectangle + width: 100; height: 100 + color: "red" + states: [ + State { + name: "blue" + PropertyChanges { target: myRectangle; color: "blue" } + }, + State { + name: "bordered" + extend: "blue" + PropertyChanges { target: myRectangle; border.width: 2 } + }] +} diff --git a/tests/auto/declarative/qmlstates/data/deleting.qml b/tests/auto/declarative/qmlstates/data/deleting.qml new file mode 100644 index 0000000..3da0b12 --- /dev/null +++ b/tests/auto/declarative/qmlstates/data/deleting.qml @@ -0,0 +1,11 @@ +import Qt 4.6 +Rectangle { + id: myRectangle + width: 100; height: 100 + color: "red" + states: State { + name: "blue" + PropertyChanges { target: myRectangle; color: "blue"; objectName: "pc1" } + PropertyChanges { target: myRectangle; radius: 5; objectName: "pc2" } + } +} diff --git a/tests/auto/declarative/qmlstates/data/deletingState.qml b/tests/auto/declarative/qmlstates/data/deletingState.qml new file mode 100644 index 0000000..a5e8ed3 --- /dev/null +++ b/tests/auto/declarative/qmlstates/data/deletingState.qml @@ -0,0 +1,13 @@ +import Qt 4.6 +Rectangle { + id: myRectangle + width: 100; height: 100 + color: "red" + StateGroup { + id: stateGroup + states: State { + name: "blue" + PropertyChanges { target: myRectangle; color: "blue" } + } + } +} diff --git a/tests/auto/declarative/qmlstates/data/explicit.qml b/tests/auto/declarative/qmlstates/data/explicit.qml new file mode 100644 index 0000000..7543f84 --- /dev/null +++ b/tests/auto/declarative/qmlstates/data/explicit.qml @@ -0,0 +1,15 @@ +import Qt 4.6 +Rectangle { + id: myRectangle + property color sourceColor: "blue" + width: 100; height: 100 + color: "red" + states: State { + name: "blue" + PropertyChanges { + objectName: "changes" + target: myRectangle; explicit: true + color: sourceColor + } + } +} diff --git a/tests/auto/declarative/qmlstates/data/fakeExtension.qml b/tests/auto/declarative/qmlstates/data/fakeExtension.qml new file mode 100644 index 0000000..c7975e1 --- /dev/null +++ b/tests/auto/declarative/qmlstates/data/fakeExtension.qml @@ -0,0 +1,16 @@ +import Qt 4.6 +Rectangle { + id: myRectangle + width: 100; height: 100 + color: "red" + states: [ + State { + name: "blue" + PropertyChanges { target: myRectangle; color: "blue" } + }, + State { + name: "green" + extend: "blue" + PropertyChanges { target: myRectangle; color: "green" } + }] +} diff --git a/tests/auto/declarative/qmlstates/data/illegalTempState.qml b/tests/auto/declarative/qmlstates/data/illegalTempState.qml new file mode 100644 index 0000000..2702be4 --- /dev/null +++ b/tests/auto/declarative/qmlstates/data/illegalTempState.qml @@ -0,0 +1,21 @@ +import Qt 4.6 + +Rectangle { + id: card + width: 100; height: 100 + + states: [ + State { + name: "placed" + PropertyChanges { target: card; state: "idle" } + }, + State { + name: "idle" + } + ] + + MouseRegion { + anchors.fill: parent + onClicked: card.state = "placed" + } +} diff --git a/tests/auto/declarative/qmlstates/data/legalTempState.qml b/tests/auto/declarative/qmlstates/data/legalTempState.qml new file mode 100644 index 0000000..54c97b9 --- /dev/null +++ b/tests/auto/declarative/qmlstates/data/legalTempState.qml @@ -0,0 +1,23 @@ +import Qt 4.6 + +Rectangle { + id: card + width: 100; height: 100 + + states: [ + State { + name: "placed" + onCompleted: card.state = "idle" + StateChangeScript { script: console.log("entering placed") } + }, + State { + name: "idle" + StateChangeScript { script: console.log("entering idle") } + } + ] + + MouseRegion { + anchors.fill: parent + onClicked: card.state = "placed" + } +} diff --git a/tests/auto/declarative/qmlstates/data/nonExistantProp.qml b/tests/auto/declarative/qmlstates/data/nonExistantProp.qml new file mode 100644 index 0000000..a5dd86a --- /dev/null +++ b/tests/auto/declarative/qmlstates/data/nonExistantProp.qml @@ -0,0 +1,11 @@ +import Qt 4.6 +Rectangle { + id: myRectangle + + width: 100; height: 100 + color: "red" + states: State { + name: "blue" + PropertyChanges { target: myRectangle; colr: "blue" } + } +} diff --git a/tests/auto/declarative/qmlstates/data/parentChange.qml b/tests/auto/declarative/qmlstates/data/parentChange.qml new file mode 100644 index 0000000..087da6b --- /dev/null +++ b/tests/auto/declarative/qmlstates/data/parentChange.qml @@ -0,0 +1,37 @@ +import Qt 4.6 + +Rectangle { + width: 400; height: 400 + Item { + x: 10; y: 10 + Rectangle { + id: myRect + objectName: "MyRect" + x: 5 + width: 100; height: 100 + color: "red" + } + } + MouseRegion { + id: clickable + anchors.fill: parent + } + + Item { + x: -100; y: -50 + Item { + id: newParent + objectName: "NewParent" + x: 248; y: 360 + } + } + + states: State { + name: "reparented" + when: clickable.pressed + ParentChange { + target: myRect + parent: newParent + } + } +} diff --git a/tests/auto/declarative/qmlstates/data/parentChange2.qml b/tests/auto/declarative/qmlstates/data/parentChange2.qml new file mode 100644 index 0000000..f0b00f5 --- /dev/null +++ b/tests/auto/declarative/qmlstates/data/parentChange2.qml @@ -0,0 +1,31 @@ +import Qt 4.6 + +Rectangle { + id: newParent + width: 400; height: 400 + Item { + scale: .5 + rotation: 15 + x: 10; y: 10 + Rectangle { + id: myRect + objectName: "MyRect" + x: 5 + width: 100; height: 100 + color: "red" + } + } + MouseRegion { + id: clickable + anchors.fill: parent + } + + states: State { + name: "reparented" + when: clickable.pressed + ParentChange { + target: myRect + parent: newParent + } + } +} diff --git a/tests/auto/declarative/qmlstates/data/parentChange3.qml b/tests/auto/declarative/qmlstates/data/parentChange3.qml new file mode 100644 index 0000000..2aa507c --- /dev/null +++ b/tests/auto/declarative/qmlstates/data/parentChange3.qml @@ -0,0 +1,42 @@ +import Qt 4.6 + +Rectangle { + width: 400; height: 400 + Item { + scale: .5 + rotation: 15 + transformOrigin: "Center" + x: 10; y: 10 + Rectangle { + id: myRect + objectName: "MyRect" + x: 5 + width: 100; height: 100 + transformOrigin: "BottomLeft" + color: "red" + } + } + MouseRegion { + id: clickable + anchors.fill: parent + } + + Item { + x: 200; y: 200 + rotation: 52; + scale: 2 + Item { + id: newParent + x: 100; y: 100 + } + } + + states: State { + name: "reparented" + when: clickable.pressed + ParentChange { + target: myRect + parent: newParent + } + } +} diff --git a/tests/auto/declarative/qmlstates/data/parentChange4.qml b/tests/auto/declarative/qmlstates/data/parentChange4.qml new file mode 100644 index 0000000..d00274b --- /dev/null +++ b/tests/auto/declarative/qmlstates/data/parentChange4.qml @@ -0,0 +1,30 @@ +import Qt 4.6 + +Rectangle { + width: 400; height: 400 + Rectangle { + id: myRect + objectName: "MyRect" + x: 5; y: 5 + width: 100; height: 100 + color: "red" + } + MouseRegion { + id: clickable + anchors.fill: parent + } + + Item { + id: newParent + transform: Scale { xScale: .5; yScale: .7} + } + + states: State { + name: "reparented" + when: clickable.pressed + ParentChange { + target: myRect + parent: newParent + } + } +} diff --git a/tests/auto/declarative/qmlstates/data/parentChange5.qml b/tests/auto/declarative/qmlstates/data/parentChange5.qml new file mode 100644 index 0000000..f75e2a3 --- /dev/null +++ b/tests/auto/declarative/qmlstates/data/parentChange5.qml @@ -0,0 +1,30 @@ +import Qt 4.6 + +Rectangle { + width: 400; height: 400 + Rectangle { + id: myRect + objectName: "MyRect" + x: 5; y: 5 + width: 100; height: 100 + color: "red" + } + MouseRegion { + id: clickable + anchors.fill: parent + } + + Item { + id: newParent + transform: Rotation { angle: 30; axis { x: 0; y: 1; z: 0 } } + } + + states: State { + name: "reparented" + when: clickable.pressed + ParentChange { + target: myRect + parent: newParent + } + } +} diff --git a/tests/auto/declarative/qmlstates/data/propertyErrors.qml b/tests/auto/declarative/qmlstates/data/propertyErrors.qml new file mode 100644 index 0000000..080e833 --- /dev/null +++ b/tests/auto/declarative/qmlstates/data/propertyErrors.qml @@ -0,0 +1,10 @@ +import Qt 4.6 +Rectangle { + id: myRectangle + width: 100; height: 100 + color: "red" + states: State { + name: "blue" + PropertyChanges { target: myRectangle; colr: "blue"; wantsFocus: true } + } +} diff --git a/tests/auto/declarative/qmlstates/data/restoreEntryValues.qml b/tests/auto/declarative/qmlstates/data/restoreEntryValues.qml new file mode 100644 index 0000000..088c608 --- /dev/null +++ b/tests/auto/declarative/qmlstates/data/restoreEntryValues.qml @@ -0,0 +1,14 @@ +import Qt 4.6 +Rectangle { + id: myRectangle + width: 100; height: 100 + color: "red" + states: State { + name: "blue" + PropertyChanges { + target: myRectangle + restoreEntryValues: false + color: "blue" + } + } +} diff --git a/tests/auto/declarative/qmlstates/data/script.qml b/tests/auto/declarative/qmlstates/data/script.qml new file mode 100644 index 0000000..3c5f33e --- /dev/null +++ b/tests/auto/declarative/qmlstates/data/script.qml @@ -0,0 +1,10 @@ +import Qt 4.6 +Rectangle { + id: myRectangle + width: 100; height: 100 + color: "red" + states: State { + name: "blue" + StateChangeScript { script: myRectangle.color = "blue"; } + } +} diff --git a/tests/auto/declarative/qmlstates/data/signalOverride.qml b/tests/auto/declarative/qmlstates/data/signalOverride.qml new file mode 100644 index 0000000..5ba1566 --- /dev/null +++ b/tests/auto/declarative/qmlstates/data/signalOverride.qml @@ -0,0 +1,18 @@ +import Qt 4.6 +import Qt.test 1.0 + +MyRectangle { + id: rect + + onDidSomething: color = "blue" + + width: 100; height: 100 + color: "red" + states: State { + name: "green" + PropertyChanges { + target: rect + onDidSomething: color = "green" + } + } +} diff --git a/tests/auto/declarative/qmlstates/data/signalOverride2.qml b/tests/auto/declarative/qmlstates/data/signalOverride2.qml new file mode 100644 index 0000000..527e165 --- /dev/null +++ b/tests/auto/declarative/qmlstates/data/signalOverride2.qml @@ -0,0 +1,9 @@ +import Qt 4.6 +import Qt.test 1.0 + +MyRectangle { + id: rect + onDidSomething: color = "blue" + width: 100; height: 100 + ExtendedRectangle {} +} diff --git a/tests/auto/declarative/qmlstates/data/signalOverrideCrash.qml b/tests/auto/declarative/qmlstates/data/signalOverrideCrash.qml new file mode 100644 index 0000000..702fa86 --- /dev/null +++ b/tests/auto/declarative/qmlstates/data/signalOverrideCrash.qml @@ -0,0 +1,15 @@ +import Qt 4.6 +import Qt.test 1.0 + +MyRectangle { + id: rect + + width: 100; height: 100 + states: State { + name: "overridden" + PropertyChanges { + target: rect + onDidSomething: rect.state = "" + } + } +} diff --git a/tests/auto/declarative/qmlstates/qmlstates.pro b/tests/auto/declarative/qmlstates/qmlstates.pro new file mode 100644 index 0000000..538734a --- /dev/null +++ b/tests/auto/declarative/qmlstates/qmlstates.pro @@ -0,0 +1,8 @@ +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 new file mode 100644 index 0000000..9e3387f --- /dev/null +++ b/tests/auto/declarative/qmlstates/tst_qmlstates.cpp @@ -0,0 +1,887 @@ +/**************************************************************************** +** +** 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 +#include +#include +#include +#include +#include +#include + +class tst_states : public QObject +{ + Q_OBJECT +public: + tst_states() {} + +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_states::fullDataPath(const QString &path) +{ + return QUrl::fromLocalFile(SRCDIR + path).toString().toUtf8(); +} + +void tst_states::basicChanges() +{ + QmlEngine engine; + + { + QmlComponent rectComponent(&engine, SRCDIR "/data/basicChanges.qml"); + QmlGraphicsRectangle *rect = qobject_cast(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(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(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_states::basicExtension() +{ + QmlEngine engine; + + { + QmlComponent rectComponent(&engine, SRCDIR "/data/basicExtension.qml"); + QmlGraphicsRectangle *rect = qobject_cast(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(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_states::basicBinding() +{ + QmlEngine engine; + + { + QmlComponent rectComponent(&engine, SRCDIR "/data/basicBinding.qml"); + QmlGraphicsRectangle *rect = qobject_cast(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(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(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(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_states::signalOverride() +{ + QmlEngine engine; + + { + QmlComponent rectComponent(&engine, SRCDIR "/data/signalOverride.qml"); + MyRect *rect = qobject_cast(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(rectComponent.create()); + QVERIFY(rect != 0); + + QCOMPARE(rect->color(),QColor("white")); + rect->doSomething(); + QCOMPARE(rect->color(),QColor("blue")); + + QmlGraphicsRectangle *innerRect = qobject_cast(rect->findChild("extendedRect")); + + innerRect->setState("green"); + rect->doSomething(); + QCOMPARE(rect->color(),QColor("blue")); + QCOMPARE(innerRect->color(),QColor("green")); + QCOMPARE(innerRect->property("extendedColor").value(),QColor("green")); + } +} + +void tst_states::signalOverrideCrash() +{ + QmlEngine engine; + + QmlComponent rectComponent(&engine, SRCDIR "/data/signalOverrideCrash.qml"); + MyRect *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + + rect->setState("overridden"); + rect->doSomething(); +} + +void tst_states::parentChange() +{ + QmlEngine engine; + + { + QmlComponent rectComponent(&engine, SRCDIR "/data/parentChange.qml"); + QmlGraphicsRectangle *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + + QmlGraphicsRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); + QVERIFY(innerRect != 0); + + qmlExecuteDeferred(rect->states()->at(0)); + QmlParentChange *pChange = qobject_cast(rect->states()->at(0)->changes()->at(0)); + QVERIFY(pChange != 0); + QmlGraphicsItem *nParent = qobject_cast(rect->findChild("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(rectComponent.create()); + QVERIFY(rect != 0); + + QmlGraphicsRectangle *innerRect = qobject_cast(rect->findChild("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(rectComponent.create()); + QVERIFY(rect != 0); + + QmlGraphicsRectangle *innerRect = qobject_cast(rect->findChild("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_states::parentChangeErrors() +{ + QmlEngine engine; + + { + QmlComponent rectComponent(&engine, SRCDIR "/data/parentChange4.qml"); + QmlGraphicsRectangle *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + + QmlGraphicsRectangle *innerRect = qobject_cast(rect->findChild("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(rectComponent.create()); + QVERIFY(rect != 0); + + QmlGraphicsRectangle *innerRect = qobject_cast(rect->findChild("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_states::anchorChanges() +{ + QmlEngine engine; + + QmlComponent rectComponent(&engine, SRCDIR "/data/anchorChanges.qml"); + QmlGraphicsRectangle *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + + QmlGraphicsRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); + QVERIFY(innerRect != 0); + + qmlExecuteDeferred(rect->states()->at(0)); + QmlAnchorChanges *aChanges = qobject_cast(rect->states()->at(0)->changes()->at(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_states::anchorChanges2() +{ + QmlEngine engine; + + QmlComponent rectComponent(&engine, SRCDIR "/data/anchorChanges2.qml"); + QmlGraphicsRectangle *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + + QmlGraphicsRectangle *innerRect = qobject_cast(rect->findChild("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_states::anchorChanges3() +{ + QmlEngine engine; + + QmlComponent rectComponent(&engine, SRCDIR "/data/anchorChanges3.qml"); + QmlGraphicsRectangle *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + + QmlGraphicsRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); + QVERIFY(innerRect != 0); + + QmlGraphicsItem *leftGuideline = qobject_cast(rect->findChild("LeftGuideline")); + QVERIFY(leftGuideline != 0); + + QmlGraphicsItem *bottomGuideline = qobject_cast(rect->findChild("BottomGuideline")); + QVERIFY(bottomGuideline != 0); + + qmlExecuteDeferred(rect->states()->at(0)); + QmlAnchorChanges *aChanges = qobject_cast(rect->states()->at(0)->changes()->at(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_states::anchorChanges4() +{ + QmlEngine engine; + + QmlComponent rectComponent(&engine, SRCDIR "/data/anchorChanges4.qml"); + QmlGraphicsRectangle *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + + QmlGraphicsRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); + QVERIFY(innerRect != 0); + + QmlGraphicsItem *leftGuideline = qobject_cast(rect->findChild("LeftGuideline")); + QVERIFY(leftGuideline != 0); + + QmlGraphicsItem *bottomGuideline = qobject_cast(rect->findChild("BottomGuideline")); + QVERIFY(bottomGuideline != 0); + + qmlExecuteDeferred(rect->states()->at(0)); + QmlAnchorChanges *aChanges = qobject_cast(rect->states()->at(0)->changes()->at(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_states::anchorChanges5() +{ + QmlEngine engine; + + QmlComponent rectComponent(&engine, SRCDIR "/data/anchorChanges5.qml"); + QmlGraphicsRectangle *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + + QmlGraphicsRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); + QVERIFY(innerRect != 0); + + QmlGraphicsItem *leftGuideline = qobject_cast(rect->findChild("LeftGuideline")); + QVERIFY(leftGuideline != 0); + + QmlGraphicsItem *bottomGuideline = qobject_cast(rect->findChild("BottomGuideline")); + QVERIFY(bottomGuideline != 0); + + qmlExecuteDeferred(rect->states()->at(0)); + QmlAnchorChanges *aChanges = qobject_cast(rect->states()->at(0)->changes()->at(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_states::script() +{ + QmlEngine engine; + + { + QmlComponent rectComponent(&engine, SRCDIR "/data/script.qml"); + QmlGraphicsRectangle *rect = qobject_cast(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_states::restoreEntryValues() +{ + QmlEngine engine; + + QmlComponent rectComponent(&engine, SRCDIR "/data/restoreEntryValues.qml"); + QmlGraphicsRectangle *rect = qobject_cast(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_states::explicitChanges() +{ + QmlEngine engine; + + QmlComponent rectComponent(&engine, SRCDIR "/data/explicit.qml"); + QmlGraphicsRectangle *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + + qmlExecuteDeferred(rect->states()->at(0)); + QmlPropertyChanges *changes = qobject_cast(rect->findChild("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_states::propertyErrors() +{ + QmlEngine engine; + QmlComponent rectComponent(&engine, SRCDIR "/data/propertyErrors.qml"); + QmlGraphicsRectangle *rect = qobject_cast(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-existant 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_states::incorrectRestoreBug() +{ + QmlEngine engine; + + QmlComponent rectComponent(&engine, SRCDIR "/data/basicChanges.qml"); + QmlGraphicsRectangle *rect = qobject_cast(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_states::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_states::deletingChange() +{ + QmlEngine engine; + + QmlComponent rectComponent(&engine, SRCDIR "/data/deleting.qml"); + QmlGraphicsRectangle *rect = qobject_cast(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("pc1"); + QVERIFY(pc != 0); + delete pc; + + QmlState *state = rect->findChild(); + QVERIFY(state != 0); + qmlExecuteDeferred(state); + QCOMPARE(state->changes()->count(), 1); + + rect->setState("blue"); + QCOMPARE(rect->color(),QColor("red")); + QCOMPARE(rect->radius(),qreal(5)); + + delete rect; +} + +void tst_states::deletingState() +{ + QmlEngine engine; + + QmlComponent rectComponent(&engine, SRCDIR "/data/deletingState.qml"); + QmlGraphicsRectangle *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + + QmlStateGroup *sg = rect->findChild(); + 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(); + 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_states::tempState() +{ + QmlEngine engine; + + QmlComponent rectComponent(&engine, SRCDIR "/data/legalTempState.qml"); + QmlGraphicsRectangle *rect = qobject_cast(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_states::illegalTempState() +{ + QmlEngine engine; + + QmlComponent rectComponent(&engine, SRCDIR "/data/illegalTempState.qml"); + QmlGraphicsRectangle *rect = qobject_cast(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_states::nonExistantProperty() +{ + QmlEngine engine; + + QmlComponent rectComponent(&engine, SRCDIR "/data/nonExistantProp.qml"); + QmlGraphicsRectangle *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + + QTest::ignoreMessage(QtWarningMsg, QByteArray("QML PropertyChanges (" + fullDataPath("/data/nonExistantProp.qml") + ":9:9) Cannot assign to non-existant property \"colr\"").constData()); + rect->setState("blue"); + QCOMPARE(rect->state(), QLatin1String("blue")); +} + +QTEST_MAIN(tst_states) + +#include "tst_states.moc" diff --git a/tests/auto/declarative/qmlvaluetypes/data/autoBindingRemoval.2.qml b/tests/auto/declarative/qmlvaluetypes/data/autoBindingRemoval.2.qml new file mode 100644 index 0000000..ce2e82d --- /dev/null +++ b/tests/auto/declarative/qmlvaluetypes/data/autoBindingRemoval.2.qml @@ -0,0 +1,9 @@ +import Test 1.0 + +MyTypeObject { + property int value: 10 + rect.x: value + + onRunScript: { rect = Qt.rect(10, 10, 10, 10) } +} + diff --git a/tests/auto/declarative/qmlvaluetypes/data/autoBindingRemoval.3.qml b/tests/auto/declarative/qmlvaluetypes/data/autoBindingRemoval.3.qml new file mode 100644 index 0000000..c82b533 --- /dev/null +++ b/tests/auto/declarative/qmlvaluetypes/data/autoBindingRemoval.3.qml @@ -0,0 +1,10 @@ +import Test 1.0 + +MyTypeObject { + property var value + + rect: value + + onRunScript: { rect.x = 44 } +} + diff --git a/tests/auto/declarative/qmlvaluetypes/data/autoBindingRemoval.qml b/tests/auto/declarative/qmlvaluetypes/data/autoBindingRemoval.qml new file mode 100644 index 0000000..a8a72f5 --- /dev/null +++ b/tests/auto/declarative/qmlvaluetypes/data/autoBindingRemoval.qml @@ -0,0 +1,9 @@ +import Test 1.0 + +MyTypeObject { + property int value: 10 + rect.x: value + + onRunScript: { rect.x = 42; } +} + diff --git a/tests/auto/declarative/qmlvaluetypes/data/bindingAssignment.qml b/tests/auto/declarative/qmlvaluetypes/data/bindingAssignment.qml new file mode 100644 index 0000000..a652186 --- /dev/null +++ b/tests/auto/declarative/qmlvaluetypes/data/bindingAssignment.qml @@ -0,0 +1,7 @@ +import Test 1.0 + +MyTypeObject { + property int value: 10 + + rect.x: value +} diff --git a/tests/auto/declarative/qmlvaluetypes/data/bindingConflict.qml b/tests/auto/declarative/qmlvaluetypes/data/bindingConflict.qml new file mode 100644 index 0000000..fd25c9f --- /dev/null +++ b/tests/auto/declarative/qmlvaluetypes/data/bindingConflict.qml @@ -0,0 +1,8 @@ +import Test 1.0 + +MyTypeObject { + property int value: 13 + + rect.x: value + rect: "10,10,10x10" +} diff --git a/tests/auto/declarative/qmlvaluetypes/data/bindingRead.qml b/tests/auto/declarative/qmlvaluetypes/data/bindingRead.qml new file mode 100644 index 0000000..538d776 --- /dev/null +++ b/tests/auto/declarative/qmlvaluetypes/data/bindingRead.qml @@ -0,0 +1,5 @@ +import Test 1.0 + +MyTypeObject { + property int value: rect.x +} diff --git a/tests/auto/declarative/qmlvaluetypes/data/bindingVariantCopy.qml b/tests/auto/declarative/qmlvaluetypes/data/bindingVariantCopy.qml new file mode 100644 index 0000000..691a56c --- /dev/null +++ b/tests/auto/declarative/qmlvaluetypes/data/bindingVariantCopy.qml @@ -0,0 +1,13 @@ +import Test 1.0 + +MyTypeObject { + property var object + object: MyTypeObject { + rect.x: 19 + rect.y: 33 + rect.width: 5 + rect.height: 99 + } + + rect: object.rect +} diff --git a/tests/auto/declarative/qmlvaluetypes/data/deletedObject.js b/tests/auto/declarative/qmlvaluetypes/data/deletedObject.js new file mode 100644 index 0000000..af298ff --- /dev/null +++ b/tests/auto/declarative/qmlvaluetypes/data/deletedObject.js @@ -0,0 +1,13 @@ +var savedReference; + +function startup() +{ + savedReference = object.rect; + console.log("Test: " + savedReference.x); +} + +function afterDelete() +{ + console.log("Test: " + savedReference.x); +} + diff --git a/tests/auto/declarative/qmlvaluetypes/data/deletedObject.qml b/tests/auto/declarative/qmlvaluetypes/data/deletedObject.qml new file mode 100644 index 0000000..05459f4 --- /dev/null +++ b/tests/auto/declarative/qmlvaluetypes/data/deletedObject.qml @@ -0,0 +1,12 @@ +import Test 1.0 +import Qt 4.6 + +MyTypeObject { + property var object + + Script { source: "deletedObject.js" } + + object: MyTypeObject {} + Component.onCompleted: startup() + onRunScript: afterDelete() +} diff --git a/tests/auto/declarative/qmlvaluetypes/data/font_read.qml b/tests/auto/declarative/qmlvaluetypes/data/font_read.qml new file mode 100644 index 0000000..e1d1ce0 --- /dev/null +++ b/tests/auto/declarative/qmlvaluetypes/data/font_read.qml @@ -0,0 +1,18 @@ +import Test 1.0 + +MyTypeObject { + property string f_family: font.family + property bool f_bold: font.bold + property int f_weight: font.weight + property bool f_italic: font.italic + property bool f_underline: font.underline + property bool f_overline: font.overline + property bool f_strikeout: font.strikeout + property real f_pointSize: font.pointSize + property int f_pixelSize: font.pixelSize + property int f_capitalization: font.capitalization + property real f_letterSpacing: font.letterSpacing + property real f_wordSpacing: font.wordSpacing; + property var copy: font +} + diff --git a/tests/auto/declarative/qmlvaluetypes/data/font_write.2.qml b/tests/auto/declarative/qmlvaluetypes/data/font_write.2.qml new file mode 100644 index 0000000..b559389 --- /dev/null +++ b/tests/auto/declarative/qmlvaluetypes/data/font_write.2.qml @@ -0,0 +1,6 @@ +import Test 1.0 + +MyTypeObject { + font.pixelSize: 10 +} + diff --git a/tests/auto/declarative/qmlvaluetypes/data/font_write.3.qml b/tests/auto/declarative/qmlvaluetypes/data/font_write.3.qml new file mode 100644 index 0000000..913ac50 --- /dev/null +++ b/tests/auto/declarative/qmlvaluetypes/data/font_write.3.qml @@ -0,0 +1,7 @@ +import Test 1.0 + +MyTypeObject { + font.pixelSize: 10 + font.pointSize: 19 +} + diff --git a/tests/auto/declarative/qmlvaluetypes/data/font_write.qml b/tests/auto/declarative/qmlvaluetypes/data/font_write.qml new file mode 100644 index 0000000..ff4d0a1 --- /dev/null +++ b/tests/auto/declarative/qmlvaluetypes/data/font_write.qml @@ -0,0 +1,16 @@ +import Test 1.0 + +MyTypeObject { + font.family: if(1) "Helvetica" + font.bold: if(1) false + font.weight: "Normal" + font.italic: if(1) false + font.underline: if(1) false + font.overline: if(1) false + font.strikeout: if(1) false + font.pointSize: if(1) 15 + font.capitalization: "AllLowercase" + font.letterSpacing: if(1) 9.7 + font.wordSpacing: if(1) 11.2 +} + diff --git a/tests/auto/declarative/qmlvaluetypes/data/point_read.qml b/tests/auto/declarative/qmlvaluetypes/data/point_read.qml new file mode 100644 index 0000000..3e67de6 --- /dev/null +++ b/tests/auto/declarative/qmlvaluetypes/data/point_read.qml @@ -0,0 +1,7 @@ +import Test 1.0 + +MyTypeObject { + property int p_x: point.x + property int p_y: point.y + property var copy: point +} diff --git a/tests/auto/declarative/qmlvaluetypes/data/point_write.qml b/tests/auto/declarative/qmlvaluetypes/data/point_write.qml new file mode 100644 index 0000000..063525a --- /dev/null +++ b/tests/auto/declarative/qmlvaluetypes/data/point_write.qml @@ -0,0 +1,6 @@ +import Test 1.0 + +MyTypeObject { + point.x: if (true) 11 + point.y: if (true) 12 +} diff --git a/tests/auto/declarative/qmlvaluetypes/data/pointf_read.qml b/tests/auto/declarative/qmlvaluetypes/data/pointf_read.qml new file mode 100644 index 0000000..d845a5b --- /dev/null +++ b/tests/auto/declarative/qmlvaluetypes/data/pointf_read.qml @@ -0,0 +1,8 @@ +import Test 1.0 + +MyTypeObject { + property real p_x: pointf.x + property real p_y: pointf.y + property var copy: pointf +} + diff --git a/tests/auto/declarative/qmlvaluetypes/data/pointf_write.qml b/tests/auto/declarative/qmlvaluetypes/data/pointf_write.qml new file mode 100644 index 0000000..9ee3fc1 --- /dev/null +++ b/tests/auto/declarative/qmlvaluetypes/data/pointf_write.qml @@ -0,0 +1,6 @@ +import Test 1.0 + +MyTypeObject { + pointf.x: if (true) 6.8 + pointf.y: if (true) 9.3 +} diff --git a/tests/auto/declarative/qmlvaluetypes/data/rect_read.qml b/tests/auto/declarative/qmlvaluetypes/data/rect_read.qml new file mode 100644 index 0000000..5364431 --- /dev/null +++ b/tests/auto/declarative/qmlvaluetypes/data/rect_read.qml @@ -0,0 +1,10 @@ +import Test 1.0 + +MyTypeObject { + property int r_x: rect.x + property int r_y: rect.y + property int r_width: rect.width + property int r_height: rect.height + property var copy: rect +} + diff --git a/tests/auto/declarative/qmlvaluetypes/data/rect_write.qml b/tests/auto/declarative/qmlvaluetypes/data/rect_write.qml new file mode 100644 index 0000000..8add453 --- /dev/null +++ b/tests/auto/declarative/qmlvaluetypes/data/rect_write.qml @@ -0,0 +1,9 @@ +import Test 1.0 + +MyTypeObject { + rect.x: if (true) 1234 + rect.y: if (true) 7 + rect.width: if (true) 56 + rect.height: if (true) 63 +} + diff --git a/tests/auto/declarative/qmlvaluetypes/data/rectf_read.qml b/tests/auto/declarative/qmlvaluetypes/data/rectf_read.qml new file mode 100644 index 0000000..aeb9f41 --- /dev/null +++ b/tests/auto/declarative/qmlvaluetypes/data/rectf_read.qml @@ -0,0 +1,10 @@ +import Test 1.0 + +MyTypeObject { + property real r_x: rectf.x + property real r_y: rectf.y + property real r_width: rectf.width + property real r_height: rectf.height + property var copy: rectf +} + diff --git a/tests/auto/declarative/qmlvaluetypes/data/rectf_write.qml b/tests/auto/declarative/qmlvaluetypes/data/rectf_write.qml new file mode 100644 index 0000000..1e6ff4f --- /dev/null +++ b/tests/auto/declarative/qmlvaluetypes/data/rectf_write.qml @@ -0,0 +1,9 @@ +import Test 1.0 + +MyTypeObject { + rectf.x: if (true) 70.1 + rectf.y: if (true) -113.2 + rectf.width: if (true) 80924.8 + rectf.height: if (true) 99.2 +} + diff --git a/tests/auto/declarative/qmlvaluetypes/data/scriptAccess.qml b/tests/auto/declarative/qmlvaluetypes/data/scriptAccess.qml new file mode 100644 index 0000000..96592eb --- /dev/null +++ b/tests/auto/declarative/qmlvaluetypes/data/scriptAccess.qml @@ -0,0 +1,9 @@ +import Qt 4.6 +import Test 1.0 + +MyTypeObject { + property int valuePre; + property int valuePost; + + Component.onCompleted: { valuePre = rect.x; rect.x = 19; valuePost = rect.x; } +} diff --git a/tests/auto/declarative/qmlvaluetypes/data/scriptVariantCopy.qml b/tests/auto/declarative/qmlvaluetypes/data/scriptVariantCopy.qml new file mode 100644 index 0000000..29157e8 --- /dev/null +++ b/tests/auto/declarative/qmlvaluetypes/data/scriptVariantCopy.qml @@ -0,0 +1,14 @@ +import Test 1.0 + +MyTypeObject { + property var object + object: MyTypeObject { + rect.x: 19 + rect.y: 33 + rect.width: 5 + rect.height: 99 + } + + onRunScript: rect = object.rect +} + diff --git a/tests/auto/declarative/qmlvaluetypes/data/size_read.qml b/tests/auto/declarative/qmlvaluetypes/data/size_read.qml new file mode 100644 index 0000000..86dba03 --- /dev/null +++ b/tests/auto/declarative/qmlvaluetypes/data/size_read.qml @@ -0,0 +1,8 @@ +import Test 1.0 + +MyTypeObject { + property int s_width: size.width + property int s_height: size.height + property var copy: size +} + diff --git a/tests/auto/declarative/qmlvaluetypes/data/size_write.qml b/tests/auto/declarative/qmlvaluetypes/data/size_write.qml new file mode 100644 index 0000000..2f9d10e --- /dev/null +++ b/tests/auto/declarative/qmlvaluetypes/data/size_write.qml @@ -0,0 +1,7 @@ +import Test 1.0 + +MyTypeObject { + size.width: if (true) 13 + size.height: if (true) 88 +} + diff --git a/tests/auto/declarative/qmlvaluetypes/data/sizef_read.qml b/tests/auto/declarative/qmlvaluetypes/data/sizef_read.qml new file mode 100644 index 0000000..c6f34e4 --- /dev/null +++ b/tests/auto/declarative/qmlvaluetypes/data/sizef_read.qml @@ -0,0 +1,9 @@ +import Test 1.0 + +MyTypeObject { + property real s_width: sizef.width + property real s_height: sizef.height + property var copy: sizef +} + + diff --git a/tests/auto/declarative/qmlvaluetypes/data/sizef_write.qml b/tests/auto/declarative/qmlvaluetypes/data/sizef_write.qml new file mode 100644 index 0000000..f16f0bd --- /dev/null +++ b/tests/auto/declarative/qmlvaluetypes/data/sizef_write.qml @@ -0,0 +1,6 @@ +import Test 1.0 + +MyTypeObject { + sizef.width: if (true) 44.3 + sizef.height: if (true) 92.8 +} diff --git a/tests/auto/declarative/qmlvaluetypes/data/staticAssignment.qml b/tests/auto/declarative/qmlvaluetypes/data/staticAssignment.qml new file mode 100644 index 0000000..b687f89 --- /dev/null +++ b/tests/auto/declarative/qmlvaluetypes/data/staticAssignment.qml @@ -0,0 +1,5 @@ +import Test 1.0 + +MyTypeObject { + rect.x: 9 +} diff --git a/tests/auto/declarative/qmlvaluetypes/data/valueInterceptors.qml b/tests/auto/declarative/qmlvaluetypes/data/valueInterceptors.qml new file mode 100644 index 0000000..026ae83 --- /dev/null +++ b/tests/auto/declarative/qmlvaluetypes/data/valueInterceptors.qml @@ -0,0 +1,8 @@ +import Test 1.0 + +MyTypeObject { + property int value: 13; + + rect.x: MyOffsetValueInterceptor {} + rect.x: value +} diff --git a/tests/auto/declarative/qmlvaluetypes/data/valueSources.qml b/tests/auto/declarative/qmlvaluetypes/data/valueSources.qml new file mode 100644 index 0000000..d4d4391 --- /dev/null +++ b/tests/auto/declarative/qmlvaluetypes/data/valueSources.qml @@ -0,0 +1,5 @@ +import Test 1.0 + +MyTypeObject { + rect.x: MyConstantValueSource {} +} diff --git a/tests/auto/declarative/qmlvaluetypes/data/vector3d_read.qml b/tests/auto/declarative/qmlvaluetypes/data/vector3d_read.qml new file mode 100644 index 0000000..abdf9f0 --- /dev/null +++ b/tests/auto/declarative/qmlvaluetypes/data/vector3d_read.qml @@ -0,0 +1,9 @@ +import Test 1.0 + +MyTypeObject { + property real v_x: vector.x + property real v_y: vector.y + property real v_z: vector.z + property var copy: vector +} + diff --git a/tests/auto/declarative/qmlvaluetypes/data/vector3d_write.qml b/tests/auto/declarative/qmlvaluetypes/data/vector3d_write.qml new file mode 100644 index 0000000..9c1bf76 --- /dev/null +++ b/tests/auto/declarative/qmlvaluetypes/data/vector3d_write.qml @@ -0,0 +1,8 @@ +import Test 1.0 + +MyTypeObject { + vector.x: if (true) -0.3 + vector.y: if (true) -12.9 + vector.z: if (true) 907.4 +} + diff --git a/tests/auto/declarative/qmlvaluetypes/qmlvaluetypes.pro b/tests/auto/declarative/qmlvaluetypes/qmlvaluetypes.pro new file mode 100644 index 0000000..82d067e --- /dev/null +++ b/tests/auto/declarative/qmlvaluetypes/qmlvaluetypes.pro @@ -0,0 +1,10 @@ +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 new file mode 100644 index 0000000..565eb1c --- /dev/null +++ b/tests/auto/declarative/qmlvaluetypes/testtypes.cpp @@ -0,0 +1,45 @@ +/**************************************************************************** +** +** 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 "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 new file mode 100644 index 0000000..67e32f5 --- /dev/null +++ b/tests/auto/declarative/qmlvaluetypes/testtypes.h @@ -0,0 +1,152 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ +#ifndef TESTTYPES_H +#define TESTTYPES_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +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 new file mode 100644 index 0000000..c3d08a2 --- /dev/null +++ b/tests/auto/declarative/qmlvaluetypes/tst_qmlvaluetypes.cpp @@ -0,0 +1,588 @@ +/**************************************************************************** +** +** 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 +#include +#include +#include +#include +#include "testtypes.h" + +class tst_valuetypes : public QObject +{ + Q_OBJECT +public: + tst_valuetypes() {} + +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_valuetypes::point() +{ + { + QmlComponent component(&engine, TEST_FILE("point_read.qml")); + MyTypeObject *object = qobject_cast(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(component.create()); + QVERIFY(object != 0); + + QCOMPARE(object->point(), QPoint(11, 12)); + + delete object; + } +} + +void tst_valuetypes::pointf() +{ + { + QmlComponent component(&engine, TEST_FILE("pointf_read.qml")); + MyTypeObject *object = qobject_cast(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(component.create()); + QVERIFY(object != 0); + + QCOMPARE(object->pointf(), QPointF(6.8, 9.3)); + + delete object; + } +} + +void tst_valuetypes::size() +{ + { + QmlComponent component(&engine, TEST_FILE("size_read.qml")); + MyTypeObject *object = qobject_cast(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(component.create()); + QVERIFY(object != 0); + + QCOMPARE(object->size(), QSize(13, 88)); + + delete object; + } +} + +void tst_valuetypes::sizef() +{ + { + QmlComponent component(&engine, TEST_FILE("sizef_read.qml")); + MyTypeObject *object = qobject_cast(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(component.create()); + QVERIFY(object != 0); + + QCOMPARE(object->sizef(), QSizeF(44.3, 92.8)); + + delete object; + } +} + +void tst_valuetypes::rect() +{ + { + QmlComponent component(&engine, TEST_FILE("rect_read.qml")); + MyTypeObject *object = qobject_cast(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(component.create()); + QVERIFY(object != 0); + + QCOMPARE(object->rect(), QRect(1234, 7, 56, 63)); + + delete object; + } +} + +void tst_valuetypes::rectf() +{ + { + QmlComponent component(&engine, TEST_FILE("rectf_read.qml")); + MyTypeObject *object = qobject_cast(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(component.create()); + QVERIFY(object != 0); + + QCOMPARE(object->rectf(), QRectF(70.1, -113.2, 80924.8, 99.2)); + + delete object; + } +} + +void tst_valuetypes::vector3d() +{ + { + QmlComponent component(&engine, TEST_FILE("vector3d_read.qml")); + MyTypeObject *object = qobject_cast(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(component.create()); + QVERIFY(object != 0); + + QCOMPARE(object->vector(), QVector3D(-0.3, -12.9, 907.4)); + + delete object; + } +} + +void tst_valuetypes::font() +{ + { + QmlComponent component(&engine, TEST_FILE("font_read.qml")); + MyTypeObject *object = qobject_cast(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(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(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(component.create()); + QVERIFY(object != 0); + + QCOMPARE(object->font().pixelSize(), 10); + + delete object; + } +} + +// Test bindings can write to value types +void tst_valuetypes::bindingAssignment() +{ + QmlComponent component(&engine, TEST_FILE("bindingAssignment.qml")); + MyTypeObject *object = qobject_cast(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_valuetypes::bindingRead() +{ + QmlComponent component(&engine, TEST_FILE("bindingRead.qml")); + MyTypeObject *object = qobject_cast(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_valuetypes::staticAssignment() +{ + QmlComponent component(&engine, TEST_FILE("staticAssignment.qml")); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QCOMPARE(object->rect().x(), 9); + + delete object; +} + +// Test scripts can read/write value types +void tst_valuetypes::scriptAccess() +{ + QmlComponent component(&engine, TEST_FILE("scriptAccess.qml")); + MyTypeObject *object = qobject_cast(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_valuetypes::autoBindingRemoval() +{ + { + QmlComponent component(&engine, TEST_FILE("autoBindingRemoval.qml")); + MyTypeObject *object = qobject_cast(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(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(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_valuetypes::valueSources() +{ + QmlComponent component(&engine, TEST_FILE("valueSources.qml")); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QCOMPARE(object->rect().x(), 3345); + + delete object; +} + +static void checkNoErrors(QmlComponent& component) +{ + QList 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_valuetypes::valueInterceptors() +{ + QmlComponent component(&engine, TEST_FILE("valueInterceptors.qml")); + MyTypeObject *object = qobject_cast(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_valuetypes::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_valuetypes::deletedObject() +{ + QmlComponent component(&engine, TEST_FILE("deletedObject.qml")); + QTest::ignoreMessage(QtDebugMsg, "Test: 2"); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QObject *dObject = qvariant_cast(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_valuetypes::bindingVariantCopy() +{ + QmlComponent component(&engine, TEST_FILE("bindingVariantCopy.qml")); + MyTypeObject *object = qobject_cast(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_valuetypes::scriptVariantCopy() +{ + QmlComponent component(&engine, TEST_FILE("scriptVariantCopy.qml")); + MyTypeObject *object = qobject_cast(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_valuetypes::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_valuetypes) + +#include "tst_valuetypes.moc" diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/abort.expect b/tests/auto/declarative/qmlxmlhttprequest/data/abort.expect new file mode 100644 index 0000000..f43e043 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/abort.expect @@ -0,0 +1,10 @@ +PUT /testdocument.html HTTP/1.1 +Content-Type: text/plain;charset=UTF-8 +Content-Length: 9 +Connection: Keep-Alive +Accept-Encoding: gzip +Accept-Language: en-US,* +User-Agent: Mozilla/5.0 +Host: 127.0.0.1:14445 + +Test Data \ No newline at end of file diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/abort.qml b/tests/auto/declarative/qmlxmlhttprequest/data/abort.qml new file mode 100644 index 0000000..d7b9266 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/abort.qml @@ -0,0 +1,42 @@ +import Qt 4.6 + +QtObject { + property string urlDummy + property string url + + property bool seenDone: false + property bool didNotSeeUnsent: true + property bool endStateUnsent: false + property bool dataOK: false + + Component.onCompleted: { + var x = new XMLHttpRequest; + x.open("GET", urlDummy); + x.setRequestHeader("Test-header", "TestValue"); + x.send(); + + x.onreadystatechange = function() { + if (x.readyState == XMLHttpRequest.DONE) { + seenDone = true; + } else if (x.readyState == XMLHttpRequest.UNSENT) { + didNotSeeUnsent = false; + } + } + + x.abort(); + + if (x.readyState == XMLHttpRequest.UNSENT) { + endStateUnsent = true; + } + + x.onreadystatechange = function() { + if (x.readyState == XMLHttpRequest.DONE) { + dataOK = (x.responseText == "QML Rocks!\n"); + } + } + x.open("PUT", url); + x.send("Test Data"); + } +} + + diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/abort.reply b/tests/auto/declarative/qmlxmlhttprequest/data/abort.reply new file mode 100644 index 0000000..35b11f4 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/abort.reply @@ -0,0 +1,2 @@ +HTTP/1.0 200 OK +Content-type: text/html; charset=UTF-8 diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/abort_opened.qml b/tests/auto/declarative/qmlxmlhttprequest/data/abort_opened.qml new file mode 100644 index 0000000..72a45e7 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/abort_opened.qml @@ -0,0 +1,58 @@ +import Qt 4.6 + +QtObject { + property string url: "testdocument.html" + + property bool readyState: false + property bool openedState: false + + property bool status: false + property bool statusText: false + property bool responseText: false + property bool responseXML: false + + property bool dataOK: false + + Component.onCompleted: { + var x = new XMLHttpRequest; + x.abort(); + + if (x.readyState == XMLHttpRequest.UNSENT) + readyState = true; + + x.open("PUT", url); + + x.abort(); + + x.open("GET", url); + + if (x.readyState == XMLHttpRequest.OPENED) + openedState = true; + + try { + var a = x.status; + } catch (error) { + if (error.code == DOMException.INVALID_STATE_ERR) + status = true; + } + try { + var a = x.statusText; + } catch (error) { + if (error.code == DOMException.INVALID_STATE_ERR) + statusText = true; + } + responseText = (x.responseText == ""); + responseXML = (x.responseXML == null); + + // Test to the end + x.onreadystatechange = function() { + if (x.readyState == XMLHttpRequest.DONE) { + dataOK = (x.responseText == "QML Rocks!\n"); + } + } + + + x.send() + } +} + diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/abort_unsent.qml b/tests/auto/declarative/qmlxmlhttprequest/data/abort_unsent.qml new file mode 100644 index 0000000..aa78cde --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/abort_unsent.qml @@ -0,0 +1,54 @@ +import Qt 4.6 + +QtObject { + property string url: "testdocument.html" + + property bool readyState: false + property bool openedState: false + + property bool status: false + property bool statusText: false + property bool responseText: false + property bool responseXML: false + + property bool dataOK: false + + Component.onCompleted: { + var x = new XMLHttpRequest; + x.abort(); + + if (x.readyState == XMLHttpRequest.UNSENT) + readyState = true; + + x.open("GET", url); + + if (x.readyState == XMLHttpRequest.OPENED) + openedState = true; + + try { + var a = x.status; + } catch (error) { + if (error.code == DOMException.INVALID_STATE_ERR) + status = true; + } + try { + var a = x.statusText; + } catch (error) { + if (error.code == DOMException.INVALID_STATE_ERR) + statusText = true; + } + responseText = (x.responseText == ""); + responseXML = (x.responseXML == null); + + // Test to the end + x.onreadystatechange = function() { + if (x.readyState == XMLHttpRequest.DONE) { + dataOK = (x.responseText == "QML Rocks!\n"); + } + } + + + x.send() + } +} + diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/attr.qml b/tests/auto/declarative/qmlxmlhttprequest/data/attr.qml new file mode 100644 index 0000000..9049fc7 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/attr.qml @@ -0,0 +1,80 @@ +import Qt 4.6 + +QtObject { + property bool xmlTest: false + property bool dataOK: false + + Script { + function checkAttr(documentElement, attr) + { + if (attr == null) + return; + + if (attr.name != "attr") + return; + + if (attr.value != "myvalue") + return; + + if (attr.ownerElement.tagName != documentElement.tagName) + return; + + if (attr.nodeName != "attr") + return; + + if (attr.nodeValue != "myvalue") + return; + + if (attr.nodeType != 2) + return; + + if (attr.childNodes.length != 0) + return; + + if (attr.firstChild != null) + return; + + if (attr.lastChild != null) + return; + + if (attr.previousSibling != null) + return; + + if (attr.nextSibling != null) + return; + + if (attr.attributes != null) + return; + + xmlTest = true; + } + + function checkXML(document) + { + checkAttr(document.documentElement, document.documentElement.attributes[0]); + } + } + + Component.onCompleted: { + var x = new XMLHttpRequest; + + x.open("GET", "attr.xml"); + + // Test to the end + x.onreadystatechange = function() { + if (x.readyState == XMLHttpRequest.DONE) { + + dataOK = true; + + if (x.responseXML != null) + checkXML(x.responseXML); + + } + } + + x.send() + } +} + + + diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/attr.xml b/tests/auto/declarative/qmlxmlhttprequest/data/attr.xml new file mode 100644 index 0000000..2aa64a3 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/attr.xml @@ -0,0 +1 @@ + diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/callbackException.qml b/tests/auto/declarative/qmlxmlhttprequest/data/callbackException.qml new file mode 100644 index 0000000..9255922 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/callbackException.qml @@ -0,0 +1,25 @@ +import Qt 4.6 + +QtObject { + id: obj + property string url + property string which + property bool threw: false + + onWhichChanged: { + var x = new XMLHttpRequest; + + x.onreadystatechange = function() { + if (x.readyState == which) { + obj.threw = true + throw(new Error("Exception from Callback")) + } + } + + x.open("GET", url); + x.setRequestHeader("Test-header", "TestValue"); + x.send(); + } +} + + diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/cdata.qml b/tests/auto/declarative/qmlxmlhttprequest/data/cdata.qml new file mode 100644 index 0000000..b2d0209 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/cdata.qml @@ -0,0 +1,135 @@ +import Qt 4.6 + +QtObject { + property bool xmlTest: false + property bool dataOK: false + + Script { + function checkCData(text, whitespacetext) + { + // This is essentially a copy of text.qml/checkText() + + if (text == null) + return; + + if (text.nodeName != "#cdata-section") + return; + + if (text.nodeValue != "Hello world!") + return; + + if (text.nodeType != 4) + return; + + if (text.parentNode.nodeName != "item") + return; + + if (text.childNodes.length != 0) + return; + + if (text.firstChild != null) + return; + + if (text.lastChild != null) + return; + + if (text.previousSibling != null) + return; + + if (text.nextSibling != null) + return; + + if (text.attributes != null) + return; + + if (text.wholeText != "Hello world!") + return; + + if (text.data != "Hello world!") + return; + + if (text.length != 12) + return; + + if (text.isElementContentWhitespace != false) + return; + + if (whitespacetext.nodeName != "#cdata-section") + return; + + if (whitespacetext.nodeValue != " ") + return; + + if (whitespacetext.nodeType != 4) + return; + + if (whitespacetext.parentNode.nodeName != "item") + return; + + if (whitespacetext.childNodes.length != 0) + return; + + if (whitespacetext.firstChild != null) + return; + + if (whitespacetext.lastChild != null) + return; + + if (whitespacetext.previousSibling != null) + return; + + if (whitespacetext.nextSibling != null) + return; + + if (whitespacetext.attributes != null) + return; + + if (whitespacetext.wholeText != " ") + return; + + if (whitespacetext.data != " ") + return; + + if (whitespacetext.length != 3) + return; + + if (whitespacetext.isElementContentWhitespace != true) + return; + + + xmlTest = true; + } + + function checkXML(document) + { + checkCData(document.documentElement.childNodes[0].childNodes[0], + document.documentElement.childNodes[1].childNodes[0]); + + } + } + + Component.onCompleted: { + var x = new XMLHttpRequest; + + x.open("GET", "cdata.xml"); + + // Test to the end + x.onreadystatechange = function() { + if (x.readyState == XMLHttpRequest.DONE) { + + dataOK = true; + + if (x.responseXML != null) + checkXML(x.responseXML); + + } + } + + x.send() + } +} + + + + + diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/cdata.xml b/tests/auto/declarative/qmlxmlhttprequest/data/cdata.xml new file mode 100644 index 0000000..061d37c --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/cdata.xml @@ -0,0 +1,2 @@ + + diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/constructor.qml b/tests/auto/declarative/qmlxmlhttprequest/data/constructor.qml new file mode 100644 index 0000000..93e44fd --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/constructor.qml @@ -0,0 +1,14 @@ +import Qt 4.6 + +QtObject { + property bool calledAsConstructor + property bool calledAsFunction + + Component.onCompleted: { + var x1 = new XMLHttpRequest; + var x2 = XMLHttpRequest(); + + calledAsConstructor = (x1 != null && x1 instanceof XMLHttpRequest); + calledAsFunction = (x2 == undefined); + } +} diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/defaultState.qml b/tests/auto/declarative/qmlxmlhttprequest/data/defaultState.qml new file mode 100644 index 0000000..4dcf6f9 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/defaultState.qml @@ -0,0 +1,30 @@ +import Qt 4.6 + +QtObject { + property int readyState + property bool statusIsException: false + property bool statusTextIsException: false + property string responseText + property bool responseXMLIsNull + + Component.onCompleted: { + var xhr = new XMLHttpRequest(); + + readyState = xhr.readyState; + try { + status = xhr.status; + } catch (error) { + if (error.code == DOMException.INVALID_STATE_ERR) + statusIsException = true; + } + try { + statusText = xhr.statusText; + } catch (error) { + if (error.code == DOMException.INVALID_STATE_ERR) + statusTextIsException = true; + } + responseText = xhr.responseText; + responseXMLIsNull = (xhr.responseXML == null); + } +} + diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/document.qml b/tests/auto/declarative/qmlxmlhttprequest/data/document.qml new file mode 100644 index 0000000..e372361 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/document.qml @@ -0,0 +1,58 @@ +import Qt 4.6 + +QtObject { + property bool xmlTest: false + property bool dataOK: false + + Script { + function checkXML(document) + { + if (document.xmlVersion != "1.0") + return; + + if (document.xmlEncoding != "UTF-8") + return; + + if (document.xmlStandalone != true) + return; + + if (document.documentElement == null) + return; + + if (document.nodeName != "#document") + return; + + if (document.nodeValue != null) + return; + + if (document.parentNode != null) + return; + + // ### Test other node properties + // ### test encoding (what is a valid qt encoding?) + xmlTest = true; + } + } + + Component.onCompleted: { + var x = new XMLHttpRequest; + + x.open("GET", "document.xml"); + + // Test to the end + x.onreadystatechange = function() { + if (x.readyState == XMLHttpRequest.DONE) { + + dataOK = true; + + if (x.responseXML != null) + checkXML(x.responseXML); + + } + } + + x.send() + } +} + + diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/document.xml b/tests/auto/declarative/qmlxmlhttprequest/data/document.xml new file mode 100644 index 0000000..fb693ea --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/document.xml @@ -0,0 +1,3 @@ + + + diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/domExceptionCodes.qml b/tests/auto/declarative/qmlxmlhttprequest/data/domExceptionCodes.qml new file mode 100644 index 0000000..de5ee4f --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/domExceptionCodes.qml @@ -0,0 +1,60 @@ +import Qt 4.6 + +QtObject { + property int index_size_err: DOMException.INDEX_SIZE_ERR + property int domstring_size_err: DOMException.DOMSTRING_SIZE_ERR + property int hierarchy_request_err: DOMException.HIERARCHY_REQUEST_ERR + property int wrong_document_err: DOMException.WRONG_DOCUMENT_ERR + property int invalid_character_err: DOMException.INVALID_CHARACTER_ERR + property int no_data_allowed_err: DOMException.NO_DATA_ALLOWED_ERR + property int no_modification_allowed_err: DOMException.NO_MODIFICATION_ALLOWED_ERR + property int not_found_err: DOMException.NOT_FOUND_ERR + property int not_supported_err: DOMException.NOT_SUPPORTED_ERR + property int inuse_attribute_err: DOMException.INUSE_ATTRIBUTE_ERR + property int invalid_state_err: DOMException.INVALID_STATE_ERR + property int syntax_err: DOMException.SYNTAX_ERR + property int invalid_modification_err: DOMException.INVALID_MODIFICATION_ERR + property int namespace_err: DOMException.NAMESPACE_ERR + property int invalid_access_err: DOMException.INVALID_ACCESS_ERR + property int validation_err: DOMException.VALIDATION_ERR + property int type_mismatch_err: DOMException.TYPE_MISMATCH_ERR + + Component.onCompleted: { + // Attempt to overwrite and delete values + DOMException.INDEX_SIZE_ERR = 44; + DOMException.DOMSTRING_SIZE_ERR = 44; + DOMException.HIERARCHY_REQUEST_ERR = 44; + DOMException.WRONG_DOCUMENT_ERR = 44; + DOMException.INVALID_CHARACTER_ERR = 44; + DOMException.NO_DATA_ALLOWED_ERR = 44; + DOMException.NO_MODIFICATION_ALLOWED_ERR = 44; + DOMException.NOT_FOUND_ERR = 44; + DOMException.NOT_SUPPORTED_ERR = 44; + DOMException.INUSE_ATTRIBUTE_ERR = 44; + DOMException.INVALID_STATE_ERR = 44; + DOMException.SYNTAX_ERR = 44; + DOMException.INVALID_MODIFICATION_ERR = 44; + DOMException.NAMESPACE_ERR = 44; + DOMException.INVALID_ACCESS_ERR = 44; + DOMException.VALIDATION_ERR = 44; + DOMException.TYPE_MISMATCH_ERR = 44; + + delete DOMException.INDEX_SIZE_ERR; + delete DOMException.DOMSTRING_SIZE_ERR; + delete DOMException.HIERARCHY_REQUEST_ERR; + delete DOMException.WRONG_DOCUMENT_ERR; + delete DOMException.INVALID_CHARACTER_ERR; + delete DOMException.NO_DATA_ALLOWED_ERR; + delete DOMException.NO_MODIFICATION_ALLOWED_ERR; + delete DOMException.NOT_FOUND_ERR; + delete DOMException.NOT_SUPPORTED_ERR; + delete DOMException.INUSE_ATTRIBUTE_ERR; + delete DOMException.INVALID_STATE_ERR; + delete DOMException.SYNTAX_ERR; + delete DOMException.INVALID_MODIFICATION_ERR; + delete DOMException.NAMESPACE_ERR; + delete DOMException.INVALID_ACCESS_ERR; + delete DOMException.VALIDATION_ERR; + delete DOMException.TYPE_MISMATCH_ERR; + } +} diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/element.qml b/tests/auto/declarative/qmlxmlhttprequest/data/element.qml new file mode 100644 index 0000000..78c0374 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/element.qml @@ -0,0 +1,147 @@ +import Qt 4.6 + +QtObject { + property bool xmlTest: false + property bool dataOK: false + + Script { + function checkElement(e, person, fruit) + { + if (e.tagName != "root") + return; + + if (e.nodeName != "root") + return; + + if (e.nodeValue != null) + return; + + if (e.nodeType != 1) + return; + + var childTagNames = [ "person", "fruit" ]; + + if (e.childNodes.length != childTagNames.length) + return; + + for (var ii = 0; ii < childTagNames.length; ++ii) { + if (e.childNodes[ii].tagName != childTagNames[ii]) + return; + } + + if (e.childNodes[childTagNames.length + 1] != null) + return; + + // Check writing fails + e.childNodes[0] = null; + if (e.childNodes[0] == null) + return; + + e.childNodes[10] = 10; + if (e.childNodes[10] != null) + return; + + if (e.firstChild.tagName != e.childNodes[0].tagName) + return; + + if (e.lastChild.tagName != e.childNodes[1].tagName) + return; + + if (e.previousSibling != null) + return; + + if (e.nextSibling != null) + return; + + if (e.attributes == null) + return; + + if (e.attributes.length != 2) + return; + + var attr1 = e.attributes["attr"]; + if (attr1.nodeValue != "value") + return; + + var attrIdx = e.attributes[0]; + if (attrIdx.nodeValue != "value") + return; + + var attr2 = e.attributes["attr2"]; + if (attr2.nodeValue != "value2") + return; + + var attr3 = e.attributes["attr3"]; + if (attr3 != null) + return; + + var attrIdx2 = e.attributes[11]; + if (attrIdx2 != null) + return; + + // Check writing fails + e.attributes[0] = null; + if (e.attributes[0] == null) + return; + + e.attributes["attr"] = null; + if (e.attributes["attr"] == null) + return; + + e.attributes["attr3"] = 10; + if (e.attributes["attr3"] != null) + return; + + // Check person and fruit sub elements + if (person.parentNode.nodeName != "root") + return; + + if (person.previousSibling != null) + return; + + if (person.nextSibling.nodeName != "fruit") + return; + + if (fruit.parentNode.nodeName != "root") + return; + + if (fruit.previousSibling.nodeName != "person") + return; + + if (fruit.nextSibling != null) + return; + + xmlTest = true; + } + + function checkXML(document) + { + checkElement(document.documentElement, + document.documentElement.childNodes[0], + document.documentElement.childNodes[1]); + } + } + + Component.onCompleted: { + var x = new XMLHttpRequest; + + x.open("GET", "element.xml"); + + // Test to the end + x.onreadystatechange = function() { + if (x.readyState == XMLHttpRequest.DONE) { + + dataOK = true; + + if (x.responseXML != null) + checkXML(x.responseXML); + + } + } + + x.send() + } +} + + + diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/element.xml b/tests/auto/declarative/qmlxmlhttprequest/data/element.xml new file mode 100644 index 0000000..071ffae --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/element.xml @@ -0,0 +1 @@ + diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/getAllResponseHeaders.qml b/tests/auto/declarative/qmlxmlhttprequest/data/getAllResponseHeaders.qml new file mode 100644 index 0000000..02a8083 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/getAllResponseHeaders.qml @@ -0,0 +1,65 @@ +import Qt 4.6 + +QtObject { + property string url + + property bool unsentException: false + property bool openedException: false + + property bool readyState: false + property bool openedState: false + + property bool headersReceivedState: false + property bool headersReceivedHeader: false + + property bool doneState: false + property bool doneHeader: false + + property bool dataOK: false + + Component.onCompleted: { + var x = new XMLHttpRequest; + + try { + x.getResponseHeader("Test-Header"); + } catch (e) { + if (e.code == DOMException.INVALID_STATE_ERR) + unsentException = true; + } + + if (x.readyState == XMLHttpRequest.UNSENT) + readyState = true; + + x.open("GET", url); + + if (x.readyState == XMLHttpRequest.OPENED) + openedState = true; + + try { + x.getResponseHeader("Test-Header"); + } catch (e) { + if (e.code == DOMException.INVALID_STATE_ERR) + openedException = true; + } + + var headers = "content-type: text/html; charset=UTF-8\r\ntest-header: TestValue\r\nmultitest-header: TestValue, SecondTestValue\r\ncontent-length: 11"; + + // Test to the end + x.onreadystatechange = function() { + if (x.readyState == XMLHttpRequest.HEADERS_RECEIVED) { + headersReceivedState = true; + + headersReceivedHeader = (x.getAllResponseHeaders() == headers); + } else if (x.readyState == XMLHttpRequest.DONE) { + doneState = headersReceivedState && true; + + doneHeader = (x.getAllResponseHeaders() == headers); + dataOK = (x.responseText == "QML Rocks!\n"); + } + } + + x.send() + } +} + + diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/getAllResponseHeaders_args.qml b/tests/auto/declarative/qmlxmlhttprequest/data/getAllResponseHeaders_args.qml new file mode 100644 index 0000000..37124c7 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/getAllResponseHeaders_args.qml @@ -0,0 +1,23 @@ +import Qt 4.6 + +QtObject { + property bool exceptionThrown: false + + Component.onCompleted: { + var x = new XMLHttpRequest; + + x.open("GET", "testdocument.html"); + x.send(); + + x.onreadystatechange = function() { + if (x.readyState == XMLHttpRequest.DONE) { + try { + x.getAllResponseHeaders("Test-header"); + } catch (e) { + if (e.code == DOMException.SYNTAX_ERR) + exceptionThrown = true; + } + } + } + } +} diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/getAllResponseHeaders_sent.qml b/tests/auto/declarative/qmlxmlhttprequest/data/getAllResponseHeaders_sent.qml new file mode 100644 index 0000000..505e4b1 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/getAllResponseHeaders_sent.qml @@ -0,0 +1,20 @@ +import Qt 4.6 + +QtObject { + property bool test: false + + Component.onCompleted: { + var x = new XMLHttpRequest; + + x.open("GET", "testdocument.html"); + x.send(); + + try { + x.getAllResponseHeaders(); + } catch (e) { + if (e.code == DOMException.INVALID_STATE_ERR) + test = true; + } + } +} + diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/getAllResponseHeaders_unsent.qml b/tests/auto/declarative/qmlxmlhttprequest/data/getAllResponseHeaders_unsent.qml new file mode 100644 index 0000000..20fb040 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/getAllResponseHeaders_unsent.qml @@ -0,0 +1,16 @@ +import Qt 4.6 + +QtObject { + property bool test: false + + Component.onCompleted: { + var x = new XMLHttpRequest; + + try { + x.getAllResponseHeaders(); + } catch (e) { + if (e.code == DOMException.INVALID_STATE_ERR) + test = true; + } + } +} diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader.expect b/tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader.expect new file mode 100644 index 0000000..a740c79 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader.expect @@ -0,0 +1,7 @@ +GET /testdocument.html HTTP/1.1 +Connection: Keep-Alive +Accept-Encoding: gzip +Accept-Language: en-US,* +User-Agent: Mozilla/5.0 +Host: 127.0.0.1:14445 + diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader.qml b/tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader.qml new file mode 100644 index 0000000..2f949e1 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader.qml @@ -0,0 +1,75 @@ +import Qt 4.6 + +QtObject { + property string url + + property bool unsentException: false + property bool openedException: false + + property bool readyState: false + property bool openedState: false + + property bool headersReceivedState: false + property bool headersReceivedNullHeader: false + property bool headersReceivedValidHeader: false + property bool headersReceivedMultiValidHeader: false + property bool headersReceivedCookieHeader: false + + property bool doneState: false + property bool doneNullHeader: false + property bool doneValidHeader: false + property bool doneMultiValidHeader: false + property bool doneCookieHeader: false + + property bool dataOK: false + + Component.onCompleted: { + var x = new XMLHttpRequest; + + try { + x.getResponseHeader("Test-Header"); + } catch (e) { + if (e.code == DOMException.INVALID_STATE_ERR) + unsentException = true; + } + + if (x.readyState == XMLHttpRequest.UNSENT) + readyState = true; + + x.open("GET", url); + + if (x.readyState == XMLHttpRequest.OPENED) + openedState = true; + + try { + x.getResponseHeader("Test-Header"); + } catch (e) { + if (e.code == DOMException.INVALID_STATE_ERR) + openedException = true; + } + + // Test to the end + x.onreadystatechange = function() { + if (x.readyState == XMLHttpRequest.HEADERS_RECEIVED) { + headersReceivedState = true; + + headersReceivedNullHeader = (x.getResponseHeader("Nonexistant-header") == ""); + headersReceivedValidHeader = (x.getResponseHeader("Test-HEAder") == "TestValue"); + headersReceivedMultiValidHeader = (x.getResponseHeader("MultiTest-HEAder") == "TestValue, SecondTestValue"); + headersReceivedCookieHeader = (x.getResponseHeader("Set-Cookie") == "" && x.getResponseHeader("Set-Cookie2") == ""); + } else if (x.readyState == XMLHttpRequest.DONE) { + doneState = headersReceivedState && true; + + doneNullHeader = (x.getResponseHeader("Nonexistant-header") == ""); + doneValidHeader = (x.getResponseHeader("Test-HEAder") == "TestValue"); + doneMultiValidHeader = (x.getResponseHeader("MultiTest-HEAder") == "TestValue, SecondTestValue"); + doneCookieHeader = (x.getResponseHeader("Set-Cookie") == "" && x.getResponseHeader("Set-Cookie2") == ""); + dataOK = (x.responseText == "QML Rocks!\n"); + } + } + + x.send() + } +} + + diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader.reply b/tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader.reply new file mode 100644 index 0000000..62ec67b --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader.reply @@ -0,0 +1,7 @@ +HTTP/1.0 200 OK +Content-type: text/html; charset=UTF-8 +Test-Header: TestValue +MultiTest-Header: TestValue +MultiTest-Header: SecondTestValue +Set-Cookie: mycook=Value +Set-Cookie2: mycook=Value diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader_args.qml b/tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader_args.qml new file mode 100644 index 0000000..d5aa4b1 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader_args.qml @@ -0,0 +1,23 @@ +import Qt 4.6 + +QtObject { + property bool exceptionThrown: false + + Component.onCompleted: { + var x = new XMLHttpRequest; + + x.open("GET", "testdocument.html"); + x.send(); + + x.onreadystatechange = function() { + if (x.readyState == XMLHttpRequest.DONE) { + try { + x.getResponseHeader(); + } catch (e) { + if (e.code == DOMException.SYNTAX_ERR) + exceptionThrown = true; + } + } + } + } +} diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader_sent.qml b/tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader_sent.qml new file mode 100644 index 0000000..7538ffd --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader_sent.qml @@ -0,0 +1,20 @@ +import Qt 4.6 + +QtObject { + property bool test: false + + Component.onCompleted: { + var x = new XMLHttpRequest; + + x.open("GET", "testdocument.html"); + x.send(); + + try { + x.getResponseHeader("Test-header"); + } catch (e) { + if (e.code == DOMException.INVALID_STATE_ERR) + test = true; + } + } +} + diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader_unsent.qml b/tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader_unsent.qml new file mode 100644 index 0000000..3b55802 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader_unsent.qml @@ -0,0 +1,16 @@ +import Qt 4.6 + +QtObject { + property bool test: false + + Component.onCompleted: { + var x = new XMLHttpRequest; + + try { + x.getResponseHeader("Test-header"); + } catch (e) { + if (e.code == DOMException.INVALID_STATE_ERR) + test = true; + } + } +} diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/instanceStateValues.qml b/tests/auto/declarative/qmlxmlhttprequest/data/instanceStateValues.qml new file mode 100644 index 0000000..b8d01c4 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/instanceStateValues.qml @@ -0,0 +1,33 @@ +import Qt 4.6 + +QtObject { + property int unsent + property int opened + property int headers_received + property int loading + property int done + + Component.onCompleted: { + // Attempt to overwrite and delete values + var x = new XMLHttpRequest(); + + x.UNSENT = 9; + x.OPENED = 9; + x.HEADERS_RECEIVED = 9; + x.LOADING = 9; + x.DONE = 9; + + delete x.UNSENT; + delete x.OPENED; + delete x.HEADERS_RECEIVED; + delete x.LOADING; + delete x.DONE; + + unsent = x.UNSENT + opened = x.OPENED + headers_received = x.HEADERS_RECEIVED + loading = x.LOADING + done = x.DONE + } +} + diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/invalidMethodUsage.qml b/tests/auto/declarative/qmlxmlhttprequest/data/invalidMethodUsage.qml new file mode 100644 index 0000000..b30989b --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/invalidMethodUsage.qml @@ -0,0 +1,160 @@ +import Qt 4.6 + +QtObject { + property bool onreadystatechange: false + property bool readyState: false + property bool status: false + property bool statusText: false + property bool responseText: false + property bool responseXML: false + + property bool open: false + property bool setRequestHeader: false + property bool send: false + property bool abort: false + property bool getResponseHeader: false + property bool getAllResponseHeaders: false + + Component.onCompleted: { + var o = 10; + + try { + XMLHttpRequest.prototype.onreadystatechange + } catch (e) { + if (!(e instanceof ReferenceError)) + return; + + if (e.message != "Not an XMLHttpRequest object") + return; + + onreadystatechange = true; + } + try { + XMLHttpRequest.prototype.readyState + } catch (e) { + if (!(e instanceof ReferenceError)) + return; + + if (e.message != "Not an XMLHttpRequest object") + return; + + readyState = true; + } + try { + XMLHttpRequest.prototype.status + } catch (e) { + if (!(e instanceof ReferenceError)) + return; + + if (e.message != "Not an XMLHttpRequest object") + return; + + status = true; + } + try { + XMLHttpRequest.prototype.statusText + } catch (e) { + if (!(e instanceof ReferenceError)) + return; + + if (e.message != "Not an XMLHttpRequest object") + return; + + statusText = true; + } + try { + XMLHttpRequest.prototype.responseText + } catch (e) { + if (!(e instanceof ReferenceError)) + return; + + if (e.message != "Not an XMLHttpRequest object") + return; + + responseText = true; + } + try { + XMLHttpRequest.prototype.responseXML + } catch (e) { + if (!(e instanceof ReferenceError)) + return; + + if (e.message != "Not an XMLHttpRequest object") + return; + + responseXML = true; + } + + try { + XMLHttpRequest.prototype.open.call(o); + } catch (e) { + if (!(e instanceof ReferenceError)) + return; + + if (e.message != "Not an XMLHttpRequest object") + return; + + open = true; + } + + try { + XMLHttpRequest.prototype.setRequestHeader.call(o); + } catch (e) { + if (!(e instanceof ReferenceError)) + return; + + if (e.message != "Not an XMLHttpRequest object") + return; + + setRequestHeader = true; + } + + try { + XMLHttpRequest.prototype.send.call(o); + } catch (e) { + if (!(e instanceof ReferenceError)) + return; + + if (e.message != "Not an XMLHttpRequest object") + return; + + send = true; + } + + try { + XMLHttpRequest.prototype.abort.call(o); + } catch (e) { + if (!(e instanceof ReferenceError)) + return; + + if (e.message != "Not an XMLHttpRequest object") + return; + + abort = true; + } + + try { + XMLHttpRequest.prototype.getResponseHeader.call(o); + } catch (e) { + if (!(e instanceof ReferenceError)) + return; + + if (e.message != "Not an XMLHttpRequest object") + return; + + getResponseHeader = true; + } + + try { + XMLHttpRequest.prototype.getAllResponseHeaders.call(o); + } catch (e) { + if (!(e instanceof ReferenceError)) + return; + + if (e.message != "Not an XMLHttpRequest object") + return; + + getAllResponseHeaders = true; + } + } +} diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/open.qml b/tests/auto/declarative/qmlxmlhttprequest/data/open.qml new file mode 100644 index 0000000..c06bae3 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/open.qml @@ -0,0 +1,53 @@ +import Qt 4.6 + +QtObject { + property string url + + property bool readyState: false + property bool openedState: false + + property bool status: false + property bool statusText: false + property bool responseText: false + property bool responseXML: false + + property bool dataOK: false + + Component.onCompleted: { + var x = new XMLHttpRequest; + + if (x.readyState == XMLHttpRequest.UNSENT) + readyState = true; + + x.open("GET", url); + + if (x.readyState == XMLHttpRequest.OPENED) + openedState = true; + + try { + var a = x.status; + } catch (error) { + if (error.code == DOMException.INVALID_STATE_ERR) + status = true; + } + try { + var a = x.statusText; + } catch (error) { + if (error.code == DOMException.INVALID_STATE_ERR) + statusText = true; + } + responseText = (x.responseText == ""); + responseXML = (x.responseXML == null); + + // Test to the end + x.onreadystatechange = function() { + if (x.readyState == XMLHttpRequest.DONE) { + dataOK = (x.responseText == "QML Rocks!\n"); + } + } + + + x.send() + } +} + diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/open_arg_count.1.qml b/tests/auto/declarative/qmlxmlhttprequest/data/open_arg_count.1.qml new file mode 100644 index 0000000..b6d4c32 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/open_arg_count.1.qml @@ -0,0 +1,18 @@ +import Qt 4.6 + +QtObject { + property bool exceptionThrown: false + + Component.onCompleted: { + var x = new XMLHttpRequest; + + try { + x.open("GET"); + } catch (e) { + if (e.code == DOMException.SYNTAX_ERR) + exceptionThrown = true; + } + } +} + + diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/open_arg_count.2.qml b/tests/auto/declarative/qmlxmlhttprequest/data/open_arg_count.2.qml new file mode 100644 index 0000000..8c86c20 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/open_arg_count.2.qml @@ -0,0 +1,18 @@ +import Qt 4.6 + +QtObject { + property bool exceptionThrown: false + + Component.onCompleted: { + var x = new XMLHttpRequest; + + try { + x.open("GET", "http://www.nokia.com", true, "user", "password", "extra"); + } catch (e) { + if (e.code == DOMException.SYNTAX_ERR) + exceptionThrown = true; + } + } +} + + diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/open_invalid_method.qml b/tests/auto/declarative/qmlxmlhttprequest/data/open_invalid_method.qml new file mode 100644 index 0000000..69f79ae --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/open_invalid_method.qml @@ -0,0 +1,16 @@ +import Qt 4.6 + +QtObject { + property bool exceptionThrown: false + + Component.onCompleted: { + var x = new XMLHttpRequest; + + try { + x.open("BLAH", "http://www.nokia.com"); + } catch (e) { + if (e.code == DOMException.SYNTAX_ERR) + exceptionThrown = true; + } + } +} diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/open_network.expect b/tests/auto/declarative/qmlxmlhttprequest/data/open_network.expect new file mode 100644 index 0000000..a740c79 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/open_network.expect @@ -0,0 +1,7 @@ +GET /testdocument.html HTTP/1.1 +Connection: Keep-Alive +Accept-Encoding: gzip +Accept-Language: en-US,* +User-Agent: Mozilla/5.0 +Host: 127.0.0.1:14445 + diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/open_network.reply b/tests/auto/declarative/qmlxmlhttprequest/data/open_network.reply new file mode 100644 index 0000000..35b11f4 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/open_network.reply @@ -0,0 +1,2 @@ +HTTP/1.0 200 OK +Content-type: text/html; charset=UTF-8 diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/open_network.wait b/tests/auto/declarative/qmlxmlhttprequest/data/open_network.wait new file mode 100644 index 0000000..e69de29 diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/open_sync.qml b/tests/auto/declarative/qmlxmlhttprequest/data/open_sync.qml new file mode 100644 index 0000000..1477279 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/open_sync.qml @@ -0,0 +1,17 @@ +import Qt 4.6 + +QtObject { + property bool exceptionThrown: false + + Component.onCompleted: { + var x = new XMLHttpRequest; + + try { + x.open("GET", "http://www.nokia.com", false); + } catch (e) { + if (e.code == DOMException.NOT_SUPPORTED_ERR) + exceptionThrown = true; + } + } +} + diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/open_user.qml b/tests/auto/declarative/qmlxmlhttprequest/data/open_user.qml new file mode 100644 index 0000000..19e37fa --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/open_user.qml @@ -0,0 +1,53 @@ +import Qt 4.6 + +QtObject { + property string url + + property bool readyState: false + property bool openedState: false + + property bool status: false + property bool statusText: false + property bool responseText: false + property bool responseXML: false + + property bool dataOK: false + + Component.onCompleted: { + var x = new XMLHttpRequest; + + if (x.readyState == XMLHttpRequest.UNSENT) + readyState = true; + + x.open("GET", url, true, "username", "password"); + + if (x.readyState == XMLHttpRequest.OPENED) + openedState = true; + + try { + var a = x.status; + } catch (error) { + if (error.code == DOMException.INVALID_STATE_ERR) + status = true; + } + try { + var a = x.statusText; + } catch (error) { + if (error.code == DOMException.INVALID_STATE_ERR) + statusText = true; + } + responseText = (x.responseText == ""); + responseXML = (x.responseXML == null); + + // Test to the end + x.onreadystatechange = function() { + if (x.readyState == XMLHttpRequest.DONE) { + dataOK = (x.responseText == "QML Rocks!\n"); + } + } + + + x.send() + } +} + diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/open_username.qml b/tests/auto/declarative/qmlxmlhttprequest/data/open_username.qml new file mode 100644 index 0000000..983ea14 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/open_username.qml @@ -0,0 +1,54 @@ +import Qt 4.6 + +QtObject { + property string url + + property bool readyState: false + property bool openedState: false + + property bool status: false + property bool statusText: false + property bool responseText: false + property bool responseXML: false + + property bool dataOK: false + + Component.onCompleted: { + var x = new XMLHttpRequest; + + if (x.readyState == XMLHttpRequest.UNSENT) + readyState = true; + + x.open("GET", url, true, "sampleusername", "password"); + + if (x.readyState == XMLHttpRequest.OPENED) + openedState = true; + + try { + var a = x.status; + } catch (error) { + if (error.code == DOMException.INVALID_STATE_ERR) + status = true; + } + try { + var a = x.statusText; + } catch (error) { + if (error.code == DOMException.INVALID_STATE_ERR) + statusText = true; + } + responseText = (x.responseText == ""); + responseXML = (x.responseXML == null); + + // Test to the end + x.onreadystatechange = function() { + if (x.readyState == XMLHttpRequest.DONE) { + dataOK = (x.responseText == "QML Rocks!\n"); + } + } + + + x.send() + } +} + + diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/redirectError.qml b/tests/auto/declarative/qmlxmlhttprequest/data/redirectError.qml new file mode 100644 index 0000000..6b345cc --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/redirectError.qml @@ -0,0 +1,23 @@ +import Qt 4.6 + +QtObject { + property string url + + property bool dataOK: false + property bool done: false + + Component.onCompleted: { + var x = new XMLHttpRequest; + x.open("GET", url); + + x.onreadystatechange = function() { + if (x.readyState == XMLHttpRequest.DONE) { + done = true; + dataOK = x.status == 404; + } + } + + x.send(); + } +} + diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/redirectRecur.qml b/tests/auto/declarative/qmlxmlhttprequest/data/redirectRecur.qml new file mode 100644 index 0000000..c0321dc --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/redirectRecur.qml @@ -0,0 +1,23 @@ +import Qt 4.6 + +QtObject { + property string url + + property bool dataOK: false + property bool done: false + + Component.onCompleted: { + var x = new XMLHttpRequest; + x.open("GET", url); + + x.onreadystatechange = function() { + if (x.readyState == XMLHttpRequest.DONE) { + done = true; + dataOK = x.status == 302; + } + } + + x.send(); + } +} + diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/redirects.qml b/tests/auto/declarative/qmlxmlhttprequest/data/redirects.qml new file mode 100644 index 0000000..f6fabdb --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/redirects.qml @@ -0,0 +1,22 @@ +import Qt 4.6 + +QtObject { + property string url + + property bool dataOK: false + property bool done: false + + Component.onCompleted: { + var x = new XMLHttpRequest; + x.open("GET", url); + + x.onreadystatechange = function() { + if (x.readyState == XMLHttpRequest.DONE) { + done = true; + dataOK = x.responseText == "Redirected\n"; + } + } + + x.send(); + } +} diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/redirecttarget.html b/tests/auto/declarative/qmlxmlhttprequest/data/redirecttarget.html new file mode 100644 index 0000000..95f35e0 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/redirecttarget.html @@ -0,0 +1 @@ +Redirected diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/responseText.qml b/tests/auto/declarative/qmlxmlhttprequest/data/responseText.qml new file mode 100644 index 0000000..4bb3a7a --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/responseText.qml @@ -0,0 +1,52 @@ +import Qt 4.6 + +QtObject { + property string url + property string expectedText + + property bool unsent: false + property bool opened: false + property bool sent: false + property bool headersReceived: false + + property bool loading: false + property bool done: false + + property bool reset: false + + property bool dataOK: false + + Component.onCompleted: { + var x = new XMLHttpRequest; + + unsent = (x.responseText == ""); + + x.open("GET", url); + + opened = (x.responseText == ""); + + // Test to the end + x.onreadystatechange = function() { + if (x.readyState == XMLHttpRequest.HEADERS_RECEIVED) { + headersReceived = (x.responseText == ""); + } else if (x.readyState == XMLHttpRequest.LOADING) { + if (x.responseText == expectedText) + loading = true; + } else if (x.readyState == XMLHttpRequest.DONE) { + if (x.responseText == expectedText) + done = true; + + dataOK = (x.responseText == expectedText); + + x.open("GET", url); + + reset = (x.responseText == ""); + } + } + + x.send() + + sent = (x.responseText == ""); + } +} + diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/responseXML_invalid.qml b/tests/auto/declarative/qmlxmlhttprequest/data/responseXML_invalid.qml new file mode 100644 index 0000000..63f288e --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/responseXML_invalid.qml @@ -0,0 +1,24 @@ +import Qt 4.6 + +QtObject { + property bool xmlNull: false + property bool dataOK: false + + Component.onCompleted: { + var x = new XMLHttpRequest; + + x.open("GET", "testdocument.html"); + + // Test to the end + x.onreadystatechange = function() { + if (x.readyState == XMLHttpRequest.DONE) { + dataOK = (x.responseText == "QML Rocks!\n"); + xmlNull = (x.responseXML == null); + } + } + + + x.send() + } +} + diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/seconddocument.html b/tests/auto/declarative/qmlxmlhttprequest/data/seconddocument.html new file mode 100644 index 0000000..a33f44b --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/seconddocument.html @@ -0,0 +1 @@ +This should not be read! diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/send_alreadySent.qml b/tests/auto/declarative/qmlxmlhttprequest/data/send_alreadySent.qml new file mode 100644 index 0000000..0bad7df --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/send_alreadySent.qml @@ -0,0 +1,27 @@ +import Qt 4.6 + +QtObject { + property bool dataOK: false + property bool test: false + + Component.onCompleted: { + var x = new XMLHttpRequest; + x.open("GET", "testdocument.html"); + + // Test to the end + x.onreadystatechange = function() { + if (x.readyState == XMLHttpRequest.DONE) { + dataOK = (x.responseText == "QML Rocks!\n"); + } + } + + x.send(); + + try { + x.send() + } catch (e) { + if (e.code == DOMException.INVALID_STATE_ERR) + test = true; + } + } +} diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/send_data.1.expect b/tests/auto/declarative/qmlxmlhttprequest/data/send_data.1.expect new file mode 100644 index 0000000..81dd4a0 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/send_data.1.expect @@ -0,0 +1,10 @@ +POST /testdocument.html HTTP/1.1 +Content-Type: text/plain;charset=UTF-8 +Content-Length: 12 +Connection: Keep-Alive +Accept-Encoding: gzip +Accept-Language: en-US,* +User-Agent: Mozilla/5.0 +Host: 127.0.0.1:14445 + +My Sent Data \ No newline at end of file diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/send_data.1.qml b/tests/auto/declarative/qmlxmlhttprequest/data/send_data.1.qml new file mode 100644 index 0000000..03543a9 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/send_data.1.qml @@ -0,0 +1,21 @@ +import Qt 4.6 + +QtObject { + property string url + + property bool dataOK: false + + Component.onCompleted: { + var x = new XMLHttpRequest; + x.open("POST", url); + + // Test to the end + x.onreadystatechange = function() { + if (x.readyState == XMLHttpRequest.DONE) { + dataOK = (x.responseText == "QML Rocks!\n"); + } + } + + x.send("My Sent Data"); + } +} diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/send_data.2.qml b/tests/auto/declarative/qmlxmlhttprequest/data/send_data.2.qml new file mode 100644 index 0000000..79a27b6 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/send_data.2.qml @@ -0,0 +1,23 @@ +import Qt 4.6 + +QtObject { + property string url + + property bool dataOK: false + + Component.onCompleted: { + var x = new XMLHttpRequest; + x.open("POST", url); + x.setRequestHeader("Content-Type", "text/plain;charset=UTF-8"); + + // Test to the end + x.onreadystatechange = function() { + if (x.readyState == XMLHttpRequest.DONE) { + dataOK = (x.responseText == "QML Rocks!\n"); + } + } + + x.send("My Sent Data"); + } +} + diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/send_data.3.qml b/tests/auto/declarative/qmlxmlhttprequest/data/send_data.3.qml new file mode 100644 index 0000000..e048769 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/send_data.3.qml @@ -0,0 +1,23 @@ +import Qt 4.6 + +QtObject { + property string url + + property bool dataOK: false + + Component.onCompleted: { + var x = new XMLHttpRequest; + x.open("POST", url); + x.setRequestHeader("Content-Type", "text/plain;charset=latin1"); + + // Test to the end + x.onreadystatechange = function() { + if (x.readyState == XMLHttpRequest.DONE) { + dataOK = (x.responseText == "QML Rocks!\n"); + } + } + + x.send("My Sent Data"); + } +} + diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/send_data.4.expect b/tests/auto/declarative/qmlxmlhttprequest/data/send_data.4.expect new file mode 100644 index 0000000..8fcf3ac --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/send_data.4.expect @@ -0,0 +1,10 @@ +POST /testdocument.html HTTP/1.1 +Content-Type: charset=UTF-8;text/plain +Content-Length: 12 +Connection: Keep-Alive +Accept-Encoding: gzip +Accept-Language: en-US,* +User-Agent: Mozilla/5.0 +Host: 127.0.0.1:14445 + +My Sent Data \ No newline at end of file diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/send_data.4.qml b/tests/auto/declarative/qmlxmlhttprequest/data/send_data.4.qml new file mode 100644 index 0000000..7ab0b27 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/send_data.4.qml @@ -0,0 +1,23 @@ +import Qt 4.6 + +QtObject { + property string url + + property bool dataOK: false + + Component.onCompleted: { + var x = new XMLHttpRequest; + x.open("POST", url); + x.setRequestHeader("Content-Type", "charset=UTF-8;text/plain"); + + // Test to the end + x.onreadystatechange = function() { + if (x.readyState == XMLHttpRequest.DONE) { + dataOK = (x.responseText == "QML Rocks!\n"); + } + } + + x.send("My Sent Data"); + } +} + diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/send_data.5.qml b/tests/auto/declarative/qmlxmlhttprequest/data/send_data.5.qml new file mode 100644 index 0000000..29bf2c2 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/send_data.5.qml @@ -0,0 +1,23 @@ +import Qt 4.6 + +QtObject { + property string url + + property bool dataOK: false + + Component.onCompleted: { + var x = new XMLHttpRequest; + x.open("POST", url); + x.setRequestHeader("Content-Type", "charset=latin1;text/plain"); + + // Test to the end + x.onreadystatechange = function() { + if (x.readyState == XMLHttpRequest.DONE) { + dataOK = (x.responseText == "QML Rocks!\n"); + } + } + + x.send("My Sent Data"); + } +} + diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/send_data.6.expect b/tests/auto/declarative/qmlxmlhttprequest/data/send_data.6.expect new file mode 100644 index 0000000..97e6fac --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/send_data.6.expect @@ -0,0 +1,10 @@ +PUT /testdocument.html HTTP/1.1 +Content-Type: text/plain;charset=UTF-8 +Content-Length: 12 +Connection: Keep-Alive +Accept-Encoding: gzip +Accept-Language: en-US,* +User-Agent: Mozilla/5.0 +Host: 127.0.0.1:14445 + +My Sent Data \ No newline at end of file diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/send_data.6.qml b/tests/auto/declarative/qmlxmlhttprequest/data/send_data.6.qml new file mode 100644 index 0000000..135f45c --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/send_data.6.qml @@ -0,0 +1,21 @@ +import Qt 4.6 + +QtObject { + property string url + + property bool dataOK: false + + Component.onCompleted: { + var x = new XMLHttpRequest; + x.open("PUT", url); + + // Test to the end + x.onreadystatechange = function() { + if (x.readyState == XMLHttpRequest.DONE) { + dataOK = (x.responseText == "QML Rocks!\n"); + } + } + + x.send("My Sent Data"); + } +} diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/send_data.7.qml b/tests/auto/declarative/qmlxmlhttprequest/data/send_data.7.qml new file mode 100644 index 0000000..4a09527 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/send_data.7.qml @@ -0,0 +1,23 @@ +import Qt 4.6 + +QtObject { + property string url + + property bool dataOK: false + + Component.onCompleted: { + var x = new XMLHttpRequest; + x.open("POST", url); + x.setRequestHeader("Content-Type", "text/plain"); + + // Test to the end + x.onreadystatechange = function() { + if (x.readyState == XMLHttpRequest.DONE) { + dataOK = (x.responseText == "QML Rocks!\n"); + } + } + + x.send("My Sent Data"); + } +} + diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/send_data.reply b/tests/auto/declarative/qmlxmlhttprequest/data/send_data.reply new file mode 100644 index 0000000..35b11f4 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/send_data.reply @@ -0,0 +1,2 @@ +HTTP/1.0 200 OK +Content-type: text/html; charset=UTF-8 diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/send_ignoreData.qml b/tests/auto/declarative/qmlxmlhttprequest/data/send_ignoreData.qml new file mode 100644 index 0000000..dd5fa46 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/send_ignoreData.qml @@ -0,0 +1,26 @@ +import Qt 4.6 + +QtObject { + property string reqType + property string url + + property bool dataOK: false + + Component.onCompleted: { + var x = new XMLHttpRequest; + x.open(reqType, url); + + // Test to the end + x.onreadystatechange = function() { + if (x.readyState == XMLHttpRequest.DONE) { + if (reqType == "HEAD") + dataOK = (x.responseText == ""); + else + dataOK = (x.responseText == "QML Rocks!\n"); + } + } + + x.send("Data To Ignore"); + } +} + diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/send_ignoreData.reply b/tests/auto/declarative/qmlxmlhttprequest/data/send_ignoreData.reply new file mode 100644 index 0000000..35b11f4 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/send_ignoreData.reply @@ -0,0 +1,2 @@ +HTTP/1.0 200 OK +Content-type: text/html; charset=UTF-8 diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/send_ignoreData_GET.expect b/tests/auto/declarative/qmlxmlhttprequest/data/send_ignoreData_GET.expect new file mode 100644 index 0000000..a740c79 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/send_ignoreData_GET.expect @@ -0,0 +1,7 @@ +GET /testdocument.html HTTP/1.1 +Connection: Keep-Alive +Accept-Encoding: gzip +Accept-Language: en-US,* +User-Agent: Mozilla/5.0 +Host: 127.0.0.1:14445 + diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/send_ignoreData_PUT.expect b/tests/auto/declarative/qmlxmlhttprequest/data/send_ignoreData_PUT.expect new file mode 100644 index 0000000..991bd59 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/send_ignoreData_PUT.expect @@ -0,0 +1,7 @@ +HEAD /testdocument.html HTTP/1.1 +Connection: Keep-Alive +Accept-Encoding: gzip +Accept-Language: en-US,* +User-Agent: Mozilla/5.0 +Host: 127.0.0.1:14445 + diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/send_unsent.qml b/tests/auto/declarative/qmlxmlhttprequest/data/send_unsent.qml new file mode 100644 index 0000000..7f51ecf --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/send_unsent.qml @@ -0,0 +1,16 @@ +import Qt 4.6 + +QtObject { + property bool test: false + + Component.onCompleted: { + var x = new XMLHttpRequest; + + try { + x.send(); + } catch (e) { + if (e.code == DOMException.INVALID_STATE_ERR) + test = true; + } + } +} diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader.expect b/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader.expect new file mode 100644 index 0000000..4600f2a --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader.expect @@ -0,0 +1,9 @@ +GET /testdocument.html HTTP/1.1 +TEST-HEADER: value +TEST-HEADER2: value,value2 +Connection: Keep-Alive +Accept-Encoding: gzip +Accept-Language: en-US,* +User-Agent: Mozilla/5.0 +Host: 127.0.0.1:14445 + diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader.qml b/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader.qml new file mode 100644 index 0000000..b0723aa --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader.qml @@ -0,0 +1,28 @@ +import Qt 4.6 + +QtObject { + property string url + + property bool dataOK: false + + Component.onCompleted: { + var x = new XMLHttpRequest; + + x.open("GET", url); + + x.setRequestHeader("Test-header", "value"); + x.setRequestHeader("Test-header2", "value"); + x.setRequestHeader("Test-header2", "value2"); + + // Test to the end + x.onreadystatechange = function() { + if (x.readyState == XMLHttpRequest.DONE) { + dataOK = (x.responseText == "QML Rocks!\n"); + } + } + + x.send(); + } +} + + diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader.reply b/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader.reply new file mode 100644 index 0000000..35b11f4 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader.reply @@ -0,0 +1,2 @@ +HTTP/1.0 200 OK +Content-type: text/html; charset=UTF-8 diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader_args.qml b/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader_args.qml new file mode 100644 index 0000000..8305ae1 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader_args.qml @@ -0,0 +1,18 @@ +import Qt 4.6 + +QtObject { + property bool exceptionThrown: false + + Component.onCompleted: { + var x = new XMLHttpRequest; + + x.open("GET", "testdocument.html"); + + try { + x.setRequestHeader("Test-header"); + } catch (e) { + if (e.code == DOMException.SYNTAX_ERR) + exceptionThrown = true; + } + } +} diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader_illegalName.qml b/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader_illegalName.qml new file mode 100644 index 0000000..bf31eca --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader_illegalName.qml @@ -0,0 +1,57 @@ +import Qt 4.6 + +QtObject { + property string url + property string header + + property bool readyState: false + property bool openedState: false + + property bool status: false + property bool statusText: false + property bool responseText: false + property bool responseXML: false + + property bool dataOK: false + + Component.onCompleted: { + var x = new XMLHttpRequest; + + if (x.readyState == XMLHttpRequest.UNSENT) + readyState = true; + + x.open("GET", url); + + x.setRequestHeader(header, "Value"); + + if (x.readyState == XMLHttpRequest.OPENED) + openedState = true; + + try { + var a = x.status; + } catch (error) { + if (error.code == DOMException.INVALID_STATE_ERR) + status = true; + } + try { + var a = x.statusText; + } catch (error) { + if (error.code == DOMException.INVALID_STATE_ERR) + statusText = true; + } + responseText = (x.responseText == ""); + responseXML = (x.responseXML == null); + + // Test to the end + x.onreadystatechange = function() { + if (x.readyState == XMLHttpRequest.DONE) { + dataOK = (x.responseText == "QML Rocks!\n"); + } + } + + + x.send() + } +} + + diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader_sent.qml b/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader_sent.qml new file mode 100644 index 0000000..c2bbc6e --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader_sent.qml @@ -0,0 +1,31 @@ +import Qt 4.6 + +QtObject { + property string url + property bool test: false + + property bool dataOK: false + + Component.onCompleted: { + var x = new XMLHttpRequest; + + x.open("GET", url); + + // Test to the end + x.onreadystatechange = function() { + if (x.readyState == XMLHttpRequest.DONE) { + dataOK = (x.responseText == "QML Rocks!\n"); + } + } + + x.send(); + + try { + x.setRequestHeader("Test-header", "value"); + } catch (e) { + if (e.code == DOMException.INVALID_STATE_ERR) + test = true; + } + } +} + diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader_unsent.qml b/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader_unsent.qml new file mode 100644 index 0000000..30bc93e --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader_unsent.qml @@ -0,0 +1,17 @@ +import Qt 4.6 + +QtObject { + property bool test: false + + Component.onCompleted: { + var x = new XMLHttpRequest; + + try { + x.setRequestHeader("Test-header", "value"); + } catch (e) { + if (e.code == DOMException.INVALID_STATE_ERR) + test = true; + } + } +} + diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/staticStateValues.qml b/tests/auto/declarative/qmlxmlhttprequest/data/staticStateValues.qml new file mode 100644 index 0000000..ec1c5d8 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/staticStateValues.qml @@ -0,0 +1,24 @@ +import Qt 4.6 + +QtObject { + property int unsent: XMLHttpRequest.UNSENT + property int opened: XMLHttpRequest.OPENED + property int headers_received: XMLHttpRequest.HEADERS_RECEIVED + property int loading: XMLHttpRequest.LOADING + property int done: XMLHttpRequest.DONE + + Component.onCompleted: { + // Attempt to overwrite and delete values + XMLHttpRequest.UNSENT = 9; + XMLHttpRequest.OPENED = 9; + XMLHttpRequest.HEADERS_RECEIVED = 9; + XMLHttpRequest.LOADING = 9; + XMLHttpRequest.DONE = 9; + + delete XMLHttpRequest.UNSENT; + delete XMLHttpRequest.OPENED; + delete XMLHttpRequest.HEADERS_RECEIVED; + delete XMLHttpRequest.LOADING; + delete XMLHttpRequest.DONE; + } +} diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/status.200.reply b/tests/auto/declarative/qmlxmlhttprequest/data/status.200.reply new file mode 100644 index 0000000..35b11f4 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/status.200.reply @@ -0,0 +1,2 @@ +HTTP/1.0 200 OK +Content-type: text/html; charset=UTF-8 diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/status.404.reply b/tests/auto/declarative/qmlxmlhttprequest/data/status.404.reply new file mode 100644 index 0000000..964a7a8 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/status.404.reply @@ -0,0 +1,2 @@ +HTTP/1.0 404 Document not found +Content-type: text/html; charset=UTF-8 diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/status.expect b/tests/auto/declarative/qmlxmlhttprequest/data/status.expect new file mode 100644 index 0000000..a740c79 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/status.expect @@ -0,0 +1,7 @@ +GET /testdocument.html HTTP/1.1 +Connection: Keep-Alive +Accept-Encoding: gzip +Accept-Language: en-US,* +User-Agent: Mozilla/5.0 +Host: 127.0.0.1:14445 + diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/status.qml b/tests/auto/declarative/qmlxmlhttprequest/data/status.qml new file mode 100644 index 0000000..04202c4 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/status.qml @@ -0,0 +1,77 @@ +import Qt 4.6 + +QtObject { + property string url + property int expectedStatus + + property bool unsentException: false; + property bool openedException: false; + property bool sentException: false; + + property bool headersReceived: false + property bool loading: false + property bool done: false + + property bool resetException: false + + property bool dataOK: false + + Component.onCompleted: { + var x = new XMLHttpRequest; + + try { + var a = x.status; + } catch (e) { + if (e.code == DOMException.INVALID_STATE_ERR) + unsentException = true; + } + + x.open("GET", url); + + try { + var a = x.status; + } catch (e) { + if (e.code == DOMException.INVALID_STATE_ERR) + openedException = true; + } + + // Test to the end + x.onreadystatechange = function() { + if (x.readyState == XMLHttpRequest.HEADERS_RECEIVED) { + if (x.status == expectedStatus) + headersReceived = true; + } else if (x.readyState == XMLHttpRequest.LOADING) { + if (x.status == expectedStatus) + loading = true; + } else if (x.readyState == XMLHttpRequest.DONE) { + if (x.status == expectedStatus) + done = true; + + if (expectedStatus == 404) { + dataOK = (x.responseText == ""); + } else { + dataOK = (x.responseText == "QML Rocks!\n"); + } + + x.open("GET", url); + + try { + var a = x.status; + } catch (e) { + if (e.code == DOMException.INVALID_STATE_ERR) + resetException = true; + } + + } + } + + x.send() + + try { + var a = x.status; + } catch (e) { + if (e.code == DOMException.INVALID_STATE_ERR) + sentException = true; + } + } +} diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/statusText.qml b/tests/auto/declarative/qmlxmlhttprequest/data/statusText.qml new file mode 100644 index 0000000..8becc3b --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/statusText.qml @@ -0,0 +1,77 @@ +import Qt 4.6 + +QtObject { + property string url + property string expectedStatus + + property bool unsentException: false; + property bool openedException: false; + property bool sentException: false; + + property bool headersReceived: false + property bool loading: false + property bool done: false + + property bool resetException: false + + property bool dataOK: false + + Component.onCompleted: { + var x = new XMLHttpRequest; + + try { + var a = x.statusText; + } catch (e) { + if (e.code == DOMException.INVALID_STATE_ERR) + unsentException = true; + } + + x.open("GET", url); + + try { + var a = x.statusText; + } catch (e) { + if (e.code == DOMException.INVALID_STATE_ERR) + openedException = true; + } + + // Test to the end + x.onreadystatechange = function() { + if (x.readyState == XMLHttpRequest.HEADERS_RECEIVED) { + if (x.statusText == expectedStatus) + headersReceived = true; + } else if (x.readyState == XMLHttpRequest.LOADING) { + if (x.statusText == expectedStatus) + loading = true; + } else if (x.readyState == XMLHttpRequest.DONE) { + if (x.statusText == expectedStatus) + done = true; + + if (expectedStatus != "OK") { + dataOK = (x.responseText == ""); + } else { + dataOK = (x.responseText == "QML Rocks!\n"); + } + + x.open("GET", url); + + try { + var a = x.statusText; + } catch (e) { + if (e.code == DOMException.INVALID_STATE_ERR) + resetException = true; + } + + } + } + + x.send() + + try { + var a = x.statusText; + } catch (e) { + if (e.code == DOMException.INVALID_STATE_ERR) + sentException = true; + } + } +} diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/testdocument.html b/tests/auto/declarative/qmlxmlhttprequest/data/testdocument.html new file mode 100644 index 0000000..8fe0f4b --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/testdocument.html @@ -0,0 +1 @@ +QML Rocks! diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/text.qml b/tests/auto/declarative/qmlxmlhttprequest/data/text.qml new file mode 100644 index 0000000..4615a07 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/text.qml @@ -0,0 +1,131 @@ +import Qt 4.6 + +QtObject { + property bool xmlTest: false + property bool dataOK: false + + Script { + function checkText(text, whitespacetext) + { + if (text == null) + return; + + if (text.nodeName != "#text") + return; + + if (text.nodeValue != "Hello world!") + return; + + if (text.nodeType != 3) + return; + + if (text.parentNode.nodeName != "item") + return; + + if (text.childNodes.length != 0) + return; + + if (text.firstChild != null) + return; + + if (text.lastChild != null) + return; + + if (text.previousSibling != null) + return; + + if (text.nextSibling != null) + return; + + if (text.attributes != null) + return; + + if (text.wholeText != "Hello world!") + return; + + if (text.data != "Hello world!") + return; + + if (text.length != 12) + return; + + if (text.isElementContentWhitespace != false) + return; + + if (whitespacetext.nodeName != "#text") + return; + + if (whitespacetext.nodeValue != " ") + return; + + if (whitespacetext.nodeType != 3) + return; + + if (whitespacetext.parentNode.nodeName != "item") + return; + + if (whitespacetext.childNodes.length != 0) + return; + + if (whitespacetext.firstChild != null) + return; + + if (whitespacetext.lastChild != null) + return; + + if (whitespacetext.previousSibling != null) + return; + + if (whitespacetext.nextSibling != null) + return; + + if (whitespacetext.attributes != null) + return; + + if (whitespacetext.wholeText != " ") + return; + + if (whitespacetext.data != " ") + return; + + if (whitespacetext.length != 3) + return; + + if (whitespacetext.isElementContentWhitespace != true) + return; + + xmlTest = true; + } + + function checkXML(document) + { + checkText(document.documentElement.childNodes[0].childNodes[0], + document.documentElement.childNodes[1].childNodes[0]); + + } + } + + Component.onCompleted: { + var x = new XMLHttpRequest; + + x.open("GET", "text.xml"); + + // Test to the end + x.onreadystatechange = function() { + if (x.readyState == XMLHttpRequest.DONE) { + + dataOK = true; + + if (x.responseXML != null) + checkXML(x.responseXML); + + } + } + + x.send() + } +} + + + + diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/text.xml b/tests/auto/declarative/qmlxmlhttprequest/data/text.xml new file mode 100644 index 0000000..e741688 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/text.xml @@ -0,0 +1 @@ +Hello world! diff --git a/tests/auto/declarative/qmlxmlhttprequest/qmlxmlhttprequest.pro b/tests/auto/declarative/qmlxmlhttprequest/qmlxmlhttprequest.pro new file mode 100644 index 0000000..ed87b2a --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/qmlxmlhttprequest.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_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 new file mode 100644 index 0000000..253e041 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/tst_qmlxmlhttprequest.cpp @@ -0,0 +1,1315 @@ +/**************************************************************************** +** +** 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 +#include +#include +#include +#include +#include "testhttpserver.h" + +#define SERVER_PORT 14445 + +class tst_xmlhttprequest : public QObject +{ + Q_OBJECT +public: + tst_xmlhttprequest() {} + +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_xmlhttprequest::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_xmlhttprequest::callbackException_data() +{ + QTest::addColumn("which"); + QTest::addColumn("line"); + + QTest::newRow("on-opened") << "1" << 15; + QTest::newRow("on-loading") << "3" << 15; + QTest::newRow("on-done") << "4" << 15; +} + +void tst_xmlhttprequest::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_xmlhttprequest::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_xmlhttprequest::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_xmlhttprequest::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_xmlhttprequest::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_xmlhttprequest::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_xmlhttprequest::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_xmlhttprequest::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_xmlhttprequest::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_xmlhttprequest::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_xmlhttprequest::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_xmlhttprequest::setRequestHeader_illegalName_data() +{ + QTest::addColumn("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_xmlhttprequest::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_xmlhttprequest::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_xmlhttprequest::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_xmlhttprequest::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_xmlhttprequest::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_xmlhttprequest::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_xmlhttprequest::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_xmlhttprequest::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_xmlhttprequest::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_xmlhttprequest::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_xmlhttprequest::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_xmlhttprequest::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_xmlhttprequest::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_xmlhttprequest::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_xmlhttprequest::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_xmlhttprequest::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_xmlhttprequest::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_xmlhttprequest::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_xmlhttprequest::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_xmlhttprequest::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_xmlhttprequest::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_xmlhttprequest::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_xmlhttprequest::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_xmlhttprequest::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_xmlhttprequest::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_xmlhttprequest::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_xmlhttprequest::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_xmlhttprequest::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_xmlhttprequest::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_xmlhttprequest) + +#include "tst_xmlhttprequest.moc" diff --git a/tests/auto/declarative/states/data/ExtendedRectangle.qml b/tests/auto/declarative/states/data/ExtendedRectangle.qml deleted file mode 100644 index 8d64663..0000000 --- a/tests/auto/declarative/states/data/ExtendedRectangle.qml +++ /dev/null @@ -1,19 +0,0 @@ -import Qt 4.6 -Rectangle { - id: extendedRect - objectName: "extendedRect" - property color extendedColor: "orange" - - width: 100; height: 100 - color: "red" - states: State { - name: "green" - PropertyChanges { - target: rect - onDidSomething: { - extendedRect.color = "green" - extendedColor = "green" - } - } - } -} diff --git a/tests/auto/declarative/states/data/anchorChanges.qml b/tests/auto/declarative/states/data/anchorChanges.qml deleted file mode 100644 index 7dce889..0000000 --- a/tests/auto/declarative/states/data/anchorChanges.qml +++ /dev/null @@ -1,23 +0,0 @@ -import Qt 4.6 - -Rectangle { - id: container - width: 200; height: 200 - Rectangle { - id: myRect - objectName: "MyRect" - width: 50; height: 50 - color: "green"; - anchors.left: parent.left - anchors.leftMargin: 5 - } - states: State { - name: "right" - AnchorChanges { - id: ancCh - target: myRect; - reset: "left" - right: container.right - } - } -} diff --git a/tests/auto/declarative/states/data/anchorChanges2.qml b/tests/auto/declarative/states/data/anchorChanges2.qml deleted file mode 100644 index 545345e..0000000 --- a/tests/auto/declarative/states/data/anchorChanges2.qml +++ /dev/null @@ -1,21 +0,0 @@ -import Qt 4.6 - -Rectangle { - width: 200; height: 200 - Rectangle { - id: myRect - objectName: "MyRect" - width: 50; height: 50 - color: "green"; - anchors.left: parent.left - anchors.leftMargin: 5 - } - states: State { - name: "right" - AnchorChanges { - target: myRect; - reset: "left" - right: parent.right - } - } -} diff --git a/tests/auto/declarative/states/data/anchorChanges3.qml b/tests/auto/declarative/states/data/anchorChanges3.qml deleted file mode 100644 index 9d5b317..0000000 --- a/tests/auto/declarative/states/data/anchorChanges3.qml +++ /dev/null @@ -1,29 +0,0 @@ -import Qt 4.6 - -Rectangle { - id: container - width: 200; height: 200 - Rectangle { - id: myRect - objectName: "MyRect" - color: "green"; - anchors.left: parent.left - anchors.right: rightGuideline.left - anchors.top: topGuideline.top - anchors.bottom: container.bottom - } - Item { objectName: "LeftGuideline"; id: leftGuideline; x: 10 } - Item { id: rightGuideline; x: 150 } - Item { id: topGuideline; y: 10 } - Item { objectName: "BottomGuideline"; id: bottomGuideline; y: 150 } - states: State { - name: "reanchored" - AnchorChanges { - target: myRect; - left: leftGuideline.left - right: container.right - top: container.top - bottom: bottomGuideline.bottom - } - } -} diff --git a/tests/auto/declarative/states/data/anchorChanges4.qml b/tests/auto/declarative/states/data/anchorChanges4.qml deleted file mode 100644 index f128989..0000000 --- a/tests/auto/declarative/states/data/anchorChanges4.qml +++ /dev/null @@ -1,22 +0,0 @@ -import Qt 4.6 - -Rectangle { - width: 200; height: 200 - Rectangle { - id: myRect - objectName: "MyRect" - color: "green"; - anchors.horizontalCenter: parent.horizontalCenter - anchors.verticalCenter: parent.verticalCenter - } - Item { objectName: "LeftGuideline"; id: leftGuideline; x: 10 } - Item { objectName: "BottomGuideline"; id: bottomGuideline; y: 150 } - states: State { - name: "reanchored" - AnchorChanges { - target: myRect; - horizontalCenter: bottomGuideline.horizontalCenter - verticalCenter: leftGuideline.verticalCenter - } - } -} diff --git a/tests/auto/declarative/states/data/anchorChanges5.qml b/tests/auto/declarative/states/data/anchorChanges5.qml deleted file mode 100644 index 4e6d34b..0000000 --- a/tests/auto/declarative/states/data/anchorChanges5.qml +++ /dev/null @@ -1,22 +0,0 @@ -import Qt 4.6 - -Rectangle { - width: 200; height: 200 - Rectangle { - id: myRect - objectName: "MyRect" - color: "green"; - anchors.horizontalCenter: parent.horizontalCenter - anchors.baseline: parent.baseline - } - Item { objectName: "LeftGuideline"; id: leftGuideline; x: 10 } - Item { objectName: "BottomGuideline"; id: bottomGuideline; y: 150 } - states: State { - name: "reanchored" - AnchorChanges { - target: myRect; - horizontalCenter: bottomGuideline.horizontalCenter - baseline: leftGuideline.baseline - } - } -} diff --git a/tests/auto/declarative/states/data/autoStateAtStartupRestoreBug.qml b/tests/auto/declarative/states/data/autoStateAtStartupRestoreBug.qml deleted file mode 100644 index 693a5c5..0000000 --- a/tests/auto/declarative/states/data/autoStateAtStartupRestoreBug.qml +++ /dev/null @@ -1,18 +0,0 @@ -import Qt 4.6 - -Item { - id: root - property int input: 1 - property int test: 9 - - states: [ - State { - name: "portrait" - when: root.input == 1 - PropertyChanges { - target: root - test: 3 - } - } - ] -} diff --git a/tests/auto/declarative/states/data/basicBinding.qml b/tests/auto/declarative/states/data/basicBinding.qml deleted file mode 100644 index 6528113..0000000 --- a/tests/auto/declarative/states/data/basicBinding.qml +++ /dev/null @@ -1,12 +0,0 @@ -import Qt 4.6 -Rectangle { - id: myRectangle - - property color sourceColor: "blue" - width: 100; height: 100 - color: "red" - states: State { - name: "blue" - PropertyChanges { target: myRectangle; color: sourceColor } - } -} diff --git a/tests/auto/declarative/states/data/basicBinding2.qml b/tests/auto/declarative/states/data/basicBinding2.qml deleted file mode 100644 index 2e7b4cf..0000000 --- a/tests/auto/declarative/states/data/basicBinding2.qml +++ /dev/null @@ -1,12 +0,0 @@ -import Qt 4.6 -Rectangle { - id: myRectangle - - property color sourceColor: "red" - width: 100; height: 100 - color: sourceColor - states: State { - name: "blue" - PropertyChanges { target: myRectangle; color: "blue" } - } -} diff --git a/tests/auto/declarative/states/data/basicBinding3.qml b/tests/auto/declarative/states/data/basicBinding3.qml deleted file mode 100644 index a3c47d9..0000000 --- a/tests/auto/declarative/states/data/basicBinding3.qml +++ /dev/null @@ -1,13 +0,0 @@ -import Qt 4.6 -Rectangle { - id: myRectangle - - property color sourceColor: "red" - property color sourceColor2: "blue" - width: 100; height: 100 - color: sourceColor - states: State { - name: "blue" - PropertyChanges { target: myRectangle; color: sourceColor2 } - } -} diff --git a/tests/auto/declarative/states/data/basicBinding4.qml b/tests/auto/declarative/states/data/basicBinding4.qml deleted file mode 100644 index 1f52d0e..0000000 --- a/tests/auto/declarative/states/data/basicBinding4.qml +++ /dev/null @@ -1,17 +0,0 @@ -import Qt 4.6 -Rectangle { - id: myRectangle - - property color sourceColor: "blue" - width: 100; height: 100 - color: "red" - states: [ - State { - name: "blue" - PropertyChanges { target: myRectangle; color: sourceColor } - }, - State { - name: "green" - PropertyChanges { target: myRectangle; color: "green" } - }] -} diff --git a/tests/auto/declarative/states/data/basicChanges.qml b/tests/auto/declarative/states/data/basicChanges.qml deleted file mode 100644 index 88ea256..0000000 --- a/tests/auto/declarative/states/data/basicChanges.qml +++ /dev/null @@ -1,10 +0,0 @@ -import Qt 4.6 -Rectangle { - id: myRectangle - width: 100; height: 100 - color: "red" - states: State { - name: "blue" - PropertyChanges { target: myRectangle; color: "blue" } - } -} diff --git a/tests/auto/declarative/states/data/basicChanges2.qml b/tests/auto/declarative/states/data/basicChanges2.qml deleted file mode 100644 index 4dd293f..0000000 --- a/tests/auto/declarative/states/data/basicChanges2.qml +++ /dev/null @@ -1,15 +0,0 @@ -import Qt 4.6 -Rectangle { - id: myRectangle - width: 100; height: 100 - color: "red" - states: [ - State { - name: "blue" - PropertyChanges { target: myRectangle; color: "blue" } - }, - State { - name: "green" - PropertyChanges { target: myRectangle; color: "green" } - }] -} diff --git a/tests/auto/declarative/states/data/basicChanges3.qml b/tests/auto/declarative/states/data/basicChanges3.qml deleted file mode 100644 index 62ab1d5..0000000 --- a/tests/auto/declarative/states/data/basicChanges3.qml +++ /dev/null @@ -1,15 +0,0 @@ -import Qt 4.6 -Rectangle { - id: myRectangle - width: 100; height: 100 - color: "red" - states: [ - State { - name: "blue" - PropertyChanges { target: myRectangle; color: "blue" } - }, - State { - name: "bordered" - PropertyChanges { target: myRectangle; border.width: 2 } - }] -} diff --git a/tests/auto/declarative/states/data/basicExtension.qml b/tests/auto/declarative/states/data/basicExtension.qml deleted file mode 100644 index 1836f8a..0000000 --- a/tests/auto/declarative/states/data/basicExtension.qml +++ /dev/null @@ -1,16 +0,0 @@ -import Qt 4.6 -Rectangle { - id: myRectangle - width: 100; height: 100 - color: "red" - states: [ - State { - name: "blue" - PropertyChanges { target: myRectangle; color: "blue" } - }, - State { - name: "bordered" - extend: "blue" - PropertyChanges { target: myRectangle; border.width: 2 } - }] -} diff --git a/tests/auto/declarative/states/data/deleting.qml b/tests/auto/declarative/states/data/deleting.qml deleted file mode 100644 index 3da0b12..0000000 --- a/tests/auto/declarative/states/data/deleting.qml +++ /dev/null @@ -1,11 +0,0 @@ -import Qt 4.6 -Rectangle { - id: myRectangle - width: 100; height: 100 - color: "red" - states: State { - name: "blue" - PropertyChanges { target: myRectangle; color: "blue"; objectName: "pc1" } - PropertyChanges { target: myRectangle; radius: 5; objectName: "pc2" } - } -} diff --git a/tests/auto/declarative/states/data/deletingState.qml b/tests/auto/declarative/states/data/deletingState.qml deleted file mode 100644 index a5e8ed3..0000000 --- a/tests/auto/declarative/states/data/deletingState.qml +++ /dev/null @@ -1,13 +0,0 @@ -import Qt 4.6 -Rectangle { - id: myRectangle - width: 100; height: 100 - color: "red" - StateGroup { - id: stateGroup - states: State { - name: "blue" - PropertyChanges { target: myRectangle; color: "blue" } - } - } -} diff --git a/tests/auto/declarative/states/data/explicit.qml b/tests/auto/declarative/states/data/explicit.qml deleted file mode 100644 index 7543f84..0000000 --- a/tests/auto/declarative/states/data/explicit.qml +++ /dev/null @@ -1,15 +0,0 @@ -import Qt 4.6 -Rectangle { - id: myRectangle - property color sourceColor: "blue" - width: 100; height: 100 - color: "red" - states: State { - name: "blue" - PropertyChanges { - objectName: "changes" - target: myRectangle; explicit: true - color: sourceColor - } - } -} diff --git a/tests/auto/declarative/states/data/fakeExtension.qml b/tests/auto/declarative/states/data/fakeExtension.qml deleted file mode 100644 index c7975e1..0000000 --- a/tests/auto/declarative/states/data/fakeExtension.qml +++ /dev/null @@ -1,16 +0,0 @@ -import Qt 4.6 -Rectangle { - id: myRectangle - width: 100; height: 100 - color: "red" - states: [ - State { - name: "blue" - PropertyChanges { target: myRectangle; color: "blue" } - }, - State { - name: "green" - extend: "blue" - PropertyChanges { target: myRectangle; color: "green" } - }] -} diff --git a/tests/auto/declarative/states/data/illegalTempState.qml b/tests/auto/declarative/states/data/illegalTempState.qml deleted file mode 100644 index 2702be4..0000000 --- a/tests/auto/declarative/states/data/illegalTempState.qml +++ /dev/null @@ -1,21 +0,0 @@ -import Qt 4.6 - -Rectangle { - id: card - width: 100; height: 100 - - states: [ - State { - name: "placed" - PropertyChanges { target: card; state: "idle" } - }, - State { - name: "idle" - } - ] - - MouseRegion { - anchors.fill: parent - onClicked: card.state = "placed" - } -} diff --git a/tests/auto/declarative/states/data/legalTempState.qml b/tests/auto/declarative/states/data/legalTempState.qml deleted file mode 100644 index 54c97b9..0000000 --- a/tests/auto/declarative/states/data/legalTempState.qml +++ /dev/null @@ -1,23 +0,0 @@ -import Qt 4.6 - -Rectangle { - id: card - width: 100; height: 100 - - states: [ - State { - name: "placed" - onCompleted: card.state = "idle" - StateChangeScript { script: console.log("entering placed") } - }, - State { - name: "idle" - StateChangeScript { script: console.log("entering idle") } - } - ] - - MouseRegion { - anchors.fill: parent - onClicked: card.state = "placed" - } -} diff --git a/tests/auto/declarative/states/data/nonExistantProp.qml b/tests/auto/declarative/states/data/nonExistantProp.qml deleted file mode 100644 index a5dd86a..0000000 --- a/tests/auto/declarative/states/data/nonExistantProp.qml +++ /dev/null @@ -1,11 +0,0 @@ -import Qt 4.6 -Rectangle { - id: myRectangle - - width: 100; height: 100 - color: "red" - states: State { - name: "blue" - PropertyChanges { target: myRectangle; colr: "blue" } - } -} diff --git a/tests/auto/declarative/states/data/parentChange.qml b/tests/auto/declarative/states/data/parentChange.qml deleted file mode 100644 index 087da6b..0000000 --- a/tests/auto/declarative/states/data/parentChange.qml +++ /dev/null @@ -1,37 +0,0 @@ -import Qt 4.6 - -Rectangle { - width: 400; height: 400 - Item { - x: 10; y: 10 - Rectangle { - id: myRect - objectName: "MyRect" - x: 5 - width: 100; height: 100 - color: "red" - } - } - MouseRegion { - id: clickable - anchors.fill: parent - } - - Item { - x: -100; y: -50 - Item { - id: newParent - objectName: "NewParent" - x: 248; y: 360 - } - } - - states: State { - name: "reparented" - when: clickable.pressed - ParentChange { - target: myRect - parent: newParent - } - } -} diff --git a/tests/auto/declarative/states/data/parentChange2.qml b/tests/auto/declarative/states/data/parentChange2.qml deleted file mode 100644 index f0b00f5..0000000 --- a/tests/auto/declarative/states/data/parentChange2.qml +++ /dev/null @@ -1,31 +0,0 @@ -import Qt 4.6 - -Rectangle { - id: newParent - width: 400; height: 400 - Item { - scale: .5 - rotation: 15 - x: 10; y: 10 - Rectangle { - id: myRect - objectName: "MyRect" - x: 5 - width: 100; height: 100 - color: "red" - } - } - MouseRegion { - id: clickable - anchors.fill: parent - } - - states: State { - name: "reparented" - when: clickable.pressed - ParentChange { - target: myRect - parent: newParent - } - } -} diff --git a/tests/auto/declarative/states/data/parentChange3.qml b/tests/auto/declarative/states/data/parentChange3.qml deleted file mode 100644 index 2aa507c..0000000 --- a/tests/auto/declarative/states/data/parentChange3.qml +++ /dev/null @@ -1,42 +0,0 @@ -import Qt 4.6 - -Rectangle { - width: 400; height: 400 - Item { - scale: .5 - rotation: 15 - transformOrigin: "Center" - x: 10; y: 10 - Rectangle { - id: myRect - objectName: "MyRect" - x: 5 - width: 100; height: 100 - transformOrigin: "BottomLeft" - color: "red" - } - } - MouseRegion { - id: clickable - anchors.fill: parent - } - - Item { - x: 200; y: 200 - rotation: 52; - scale: 2 - Item { - id: newParent - x: 100; y: 100 - } - } - - states: State { - name: "reparented" - when: clickable.pressed - ParentChange { - target: myRect - parent: newParent - } - } -} diff --git a/tests/auto/declarative/states/data/parentChange4.qml b/tests/auto/declarative/states/data/parentChange4.qml deleted file mode 100644 index d00274b..0000000 --- a/tests/auto/declarative/states/data/parentChange4.qml +++ /dev/null @@ -1,30 +0,0 @@ -import Qt 4.6 - -Rectangle { - width: 400; height: 400 - Rectangle { - id: myRect - objectName: "MyRect" - x: 5; y: 5 - width: 100; height: 100 - color: "red" - } - MouseRegion { - id: clickable - anchors.fill: parent - } - - Item { - id: newParent - transform: Scale { xScale: .5; yScale: .7} - } - - states: State { - name: "reparented" - when: clickable.pressed - ParentChange { - target: myRect - parent: newParent - } - } -} diff --git a/tests/auto/declarative/states/data/parentChange5.qml b/tests/auto/declarative/states/data/parentChange5.qml deleted file mode 100644 index f75e2a3..0000000 --- a/tests/auto/declarative/states/data/parentChange5.qml +++ /dev/null @@ -1,30 +0,0 @@ -import Qt 4.6 - -Rectangle { - width: 400; height: 400 - Rectangle { - id: myRect - objectName: "MyRect" - x: 5; y: 5 - width: 100; height: 100 - color: "red" - } - MouseRegion { - id: clickable - anchors.fill: parent - } - - Item { - id: newParent - transform: Rotation { angle: 30; axis { x: 0; y: 1; z: 0 } } - } - - states: State { - name: "reparented" - when: clickable.pressed - ParentChange { - target: myRect - parent: newParent - } - } -} diff --git a/tests/auto/declarative/states/data/propertyErrors.qml b/tests/auto/declarative/states/data/propertyErrors.qml deleted file mode 100644 index 080e833..0000000 --- a/tests/auto/declarative/states/data/propertyErrors.qml +++ /dev/null @@ -1,10 +0,0 @@ -import Qt 4.6 -Rectangle { - id: myRectangle - width: 100; height: 100 - color: "red" - states: State { - name: "blue" - PropertyChanges { target: myRectangle; colr: "blue"; wantsFocus: true } - } -} diff --git a/tests/auto/declarative/states/data/restoreEntryValues.qml b/tests/auto/declarative/states/data/restoreEntryValues.qml deleted file mode 100644 index 088c608..0000000 --- a/tests/auto/declarative/states/data/restoreEntryValues.qml +++ /dev/null @@ -1,14 +0,0 @@ -import Qt 4.6 -Rectangle { - id: myRectangle - width: 100; height: 100 - color: "red" - states: State { - name: "blue" - PropertyChanges { - target: myRectangle - restoreEntryValues: false - color: "blue" - } - } -} diff --git a/tests/auto/declarative/states/data/script.qml b/tests/auto/declarative/states/data/script.qml deleted file mode 100644 index 3c5f33e..0000000 --- a/tests/auto/declarative/states/data/script.qml +++ /dev/null @@ -1,10 +0,0 @@ -import Qt 4.6 -Rectangle { - id: myRectangle - width: 100; height: 100 - color: "red" - states: State { - name: "blue" - StateChangeScript { script: myRectangle.color = "blue"; } - } -} diff --git a/tests/auto/declarative/states/data/signalOverride.qml b/tests/auto/declarative/states/data/signalOverride.qml deleted file mode 100644 index 5ba1566..0000000 --- a/tests/auto/declarative/states/data/signalOverride.qml +++ /dev/null @@ -1,18 +0,0 @@ -import Qt 4.6 -import Qt.test 1.0 - -MyRectangle { - id: rect - - onDidSomething: color = "blue" - - width: 100; height: 100 - color: "red" - states: State { - name: "green" - PropertyChanges { - target: rect - onDidSomething: color = "green" - } - } -} diff --git a/tests/auto/declarative/states/data/signalOverride2.qml b/tests/auto/declarative/states/data/signalOverride2.qml deleted file mode 100644 index 527e165..0000000 --- a/tests/auto/declarative/states/data/signalOverride2.qml +++ /dev/null @@ -1,9 +0,0 @@ -import Qt 4.6 -import Qt.test 1.0 - -MyRectangle { - id: rect - onDidSomething: color = "blue" - width: 100; height: 100 - ExtendedRectangle {} -} diff --git a/tests/auto/declarative/states/data/signalOverrideCrash.qml b/tests/auto/declarative/states/data/signalOverrideCrash.qml deleted file mode 100644 index 702fa86..0000000 --- a/tests/auto/declarative/states/data/signalOverrideCrash.qml +++ /dev/null @@ -1,15 +0,0 @@ -import Qt 4.6 -import Qt.test 1.0 - -MyRectangle { - id: rect - - width: 100; height: 100 - states: State { - name: "overridden" - PropertyChanges { - target: rect - onDidSomething: rect.state = "" - } - } -} diff --git a/tests/auto/declarative/states/states.pro b/tests/auto/declarative/states/states.pro deleted file mode 100644 index a1f3b02..0000000 --- a/tests/auto/declarative/states/states.pro +++ /dev/null @@ -1,8 +0,0 @@ -load(qttest_p4) -contains(QT_CONFIG,declarative): QT += declarative -macx:CONFIG -= app_bundle - -SOURCES += tst_states.cpp - -# Define SRCDIR equal to test's source directory -DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/states/tst_states.cpp b/tests/auto/declarative/states/tst_states.cpp deleted file mode 100644 index 9e3387f..0000000 --- a/tests/auto/declarative/states/tst_states.cpp +++ /dev/null @@ -1,887 +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 -#include -#include -#include -#include -#include -#include - -class tst_states : public QObject -{ - Q_OBJECT -public: - tst_states() {} - -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_states::fullDataPath(const QString &path) -{ - return QUrl::fromLocalFile(SRCDIR + path).toString().toUtf8(); -} - -void tst_states::basicChanges() -{ - QmlEngine engine; - - { - QmlComponent rectComponent(&engine, SRCDIR "/data/basicChanges.qml"); - QmlGraphicsRectangle *rect = qobject_cast(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(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(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_states::basicExtension() -{ - QmlEngine engine; - - { - QmlComponent rectComponent(&engine, SRCDIR "/data/basicExtension.qml"); - QmlGraphicsRectangle *rect = qobject_cast(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(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_states::basicBinding() -{ - QmlEngine engine; - - { - QmlComponent rectComponent(&engine, SRCDIR "/data/basicBinding.qml"); - QmlGraphicsRectangle *rect = qobject_cast(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(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(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(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_states::signalOverride() -{ - QmlEngine engine; - - { - QmlComponent rectComponent(&engine, SRCDIR "/data/signalOverride.qml"); - MyRect *rect = qobject_cast(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(rectComponent.create()); - QVERIFY(rect != 0); - - QCOMPARE(rect->color(),QColor("white")); - rect->doSomething(); - QCOMPARE(rect->color(),QColor("blue")); - - QmlGraphicsRectangle *innerRect = qobject_cast(rect->findChild("extendedRect")); - - innerRect->setState("green"); - rect->doSomething(); - QCOMPARE(rect->color(),QColor("blue")); - QCOMPARE(innerRect->color(),QColor("green")); - QCOMPARE(innerRect->property("extendedColor").value(),QColor("green")); - } -} - -void tst_states::signalOverrideCrash() -{ - QmlEngine engine; - - QmlComponent rectComponent(&engine, SRCDIR "/data/signalOverrideCrash.qml"); - MyRect *rect = qobject_cast(rectComponent.create()); - QVERIFY(rect != 0); - - rect->setState("overridden"); - rect->doSomething(); -} - -void tst_states::parentChange() -{ - QmlEngine engine; - - { - QmlComponent rectComponent(&engine, SRCDIR "/data/parentChange.qml"); - QmlGraphicsRectangle *rect = qobject_cast(rectComponent.create()); - QVERIFY(rect != 0); - - QmlGraphicsRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); - QVERIFY(innerRect != 0); - - qmlExecuteDeferred(rect->states()->at(0)); - QmlParentChange *pChange = qobject_cast(rect->states()->at(0)->changes()->at(0)); - QVERIFY(pChange != 0); - QmlGraphicsItem *nParent = qobject_cast(rect->findChild("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(rectComponent.create()); - QVERIFY(rect != 0); - - QmlGraphicsRectangle *innerRect = qobject_cast(rect->findChild("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(rectComponent.create()); - QVERIFY(rect != 0); - - QmlGraphicsRectangle *innerRect = qobject_cast(rect->findChild("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_states::parentChangeErrors() -{ - QmlEngine engine; - - { - QmlComponent rectComponent(&engine, SRCDIR "/data/parentChange4.qml"); - QmlGraphicsRectangle *rect = qobject_cast(rectComponent.create()); - QVERIFY(rect != 0); - - QmlGraphicsRectangle *innerRect = qobject_cast(rect->findChild("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(rectComponent.create()); - QVERIFY(rect != 0); - - QmlGraphicsRectangle *innerRect = qobject_cast(rect->findChild("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_states::anchorChanges() -{ - QmlEngine engine; - - QmlComponent rectComponent(&engine, SRCDIR "/data/anchorChanges.qml"); - QmlGraphicsRectangle *rect = qobject_cast(rectComponent.create()); - QVERIFY(rect != 0); - - QmlGraphicsRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); - QVERIFY(innerRect != 0); - - qmlExecuteDeferred(rect->states()->at(0)); - QmlAnchorChanges *aChanges = qobject_cast(rect->states()->at(0)->changes()->at(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_states::anchorChanges2() -{ - QmlEngine engine; - - QmlComponent rectComponent(&engine, SRCDIR "/data/anchorChanges2.qml"); - QmlGraphicsRectangle *rect = qobject_cast(rectComponent.create()); - QVERIFY(rect != 0); - - QmlGraphicsRectangle *innerRect = qobject_cast(rect->findChild("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_states::anchorChanges3() -{ - QmlEngine engine; - - QmlComponent rectComponent(&engine, SRCDIR "/data/anchorChanges3.qml"); - QmlGraphicsRectangle *rect = qobject_cast(rectComponent.create()); - QVERIFY(rect != 0); - - QmlGraphicsRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); - QVERIFY(innerRect != 0); - - QmlGraphicsItem *leftGuideline = qobject_cast(rect->findChild("LeftGuideline")); - QVERIFY(leftGuideline != 0); - - QmlGraphicsItem *bottomGuideline = qobject_cast(rect->findChild("BottomGuideline")); - QVERIFY(bottomGuideline != 0); - - qmlExecuteDeferred(rect->states()->at(0)); - QmlAnchorChanges *aChanges = qobject_cast(rect->states()->at(0)->changes()->at(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_states::anchorChanges4() -{ - QmlEngine engine; - - QmlComponent rectComponent(&engine, SRCDIR "/data/anchorChanges4.qml"); - QmlGraphicsRectangle *rect = qobject_cast(rectComponent.create()); - QVERIFY(rect != 0); - - QmlGraphicsRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); - QVERIFY(innerRect != 0); - - QmlGraphicsItem *leftGuideline = qobject_cast(rect->findChild("LeftGuideline")); - QVERIFY(leftGuideline != 0); - - QmlGraphicsItem *bottomGuideline = qobject_cast(rect->findChild("BottomGuideline")); - QVERIFY(bottomGuideline != 0); - - qmlExecuteDeferred(rect->states()->at(0)); - QmlAnchorChanges *aChanges = qobject_cast(rect->states()->at(0)->changes()->at(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_states::anchorChanges5() -{ - QmlEngine engine; - - QmlComponent rectComponent(&engine, SRCDIR "/data/anchorChanges5.qml"); - QmlGraphicsRectangle *rect = qobject_cast(rectComponent.create()); - QVERIFY(rect != 0); - - QmlGraphicsRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); - QVERIFY(innerRect != 0); - - QmlGraphicsItem *leftGuideline = qobject_cast(rect->findChild("LeftGuideline")); - QVERIFY(leftGuideline != 0); - - QmlGraphicsItem *bottomGuideline = qobject_cast(rect->findChild("BottomGuideline")); - QVERIFY(bottomGuideline != 0); - - qmlExecuteDeferred(rect->states()->at(0)); - QmlAnchorChanges *aChanges = qobject_cast(rect->states()->at(0)->changes()->at(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_states::script() -{ - QmlEngine engine; - - { - QmlComponent rectComponent(&engine, SRCDIR "/data/script.qml"); - QmlGraphicsRectangle *rect = qobject_cast(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_states::restoreEntryValues() -{ - QmlEngine engine; - - QmlComponent rectComponent(&engine, SRCDIR "/data/restoreEntryValues.qml"); - QmlGraphicsRectangle *rect = qobject_cast(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_states::explicitChanges() -{ - QmlEngine engine; - - QmlComponent rectComponent(&engine, SRCDIR "/data/explicit.qml"); - QmlGraphicsRectangle *rect = qobject_cast(rectComponent.create()); - QVERIFY(rect != 0); - - qmlExecuteDeferred(rect->states()->at(0)); - QmlPropertyChanges *changes = qobject_cast(rect->findChild("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_states::propertyErrors() -{ - QmlEngine engine; - QmlComponent rectComponent(&engine, SRCDIR "/data/propertyErrors.qml"); - QmlGraphicsRectangle *rect = qobject_cast(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-existant 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_states::incorrectRestoreBug() -{ - QmlEngine engine; - - QmlComponent rectComponent(&engine, SRCDIR "/data/basicChanges.qml"); - QmlGraphicsRectangle *rect = qobject_cast(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_states::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_states::deletingChange() -{ - QmlEngine engine; - - QmlComponent rectComponent(&engine, SRCDIR "/data/deleting.qml"); - QmlGraphicsRectangle *rect = qobject_cast(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("pc1"); - QVERIFY(pc != 0); - delete pc; - - QmlState *state = rect->findChild(); - QVERIFY(state != 0); - qmlExecuteDeferred(state); - QCOMPARE(state->changes()->count(), 1); - - rect->setState("blue"); - QCOMPARE(rect->color(),QColor("red")); - QCOMPARE(rect->radius(),qreal(5)); - - delete rect; -} - -void tst_states::deletingState() -{ - QmlEngine engine; - - QmlComponent rectComponent(&engine, SRCDIR "/data/deletingState.qml"); - QmlGraphicsRectangle *rect = qobject_cast(rectComponent.create()); - QVERIFY(rect != 0); - - QmlStateGroup *sg = rect->findChild(); - 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(); - 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_states::tempState() -{ - QmlEngine engine; - - QmlComponent rectComponent(&engine, SRCDIR "/data/legalTempState.qml"); - QmlGraphicsRectangle *rect = qobject_cast(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_states::illegalTempState() -{ - QmlEngine engine; - - QmlComponent rectComponent(&engine, SRCDIR "/data/illegalTempState.qml"); - QmlGraphicsRectangle *rect = qobject_cast(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_states::nonExistantProperty() -{ - QmlEngine engine; - - QmlComponent rectComponent(&engine, SRCDIR "/data/nonExistantProp.qml"); - QmlGraphicsRectangle *rect = qobject_cast(rectComponent.create()); - QVERIFY(rect != 0); - - QTest::ignoreMessage(QtWarningMsg, QByteArray("QML PropertyChanges (" + fullDataPath("/data/nonExistantProp.qml") + ":9:9) Cannot assign to non-existant property \"colr\"").constData()); - rect->setState("blue"); - QCOMPARE(rect->state(), QLatin1String("blue")); -} - -QTEST_MAIN(tst_states) - -#include "tst_states.moc" diff --git a/tests/auto/declarative/valuetypes/data/autoBindingRemoval.2.qml b/tests/auto/declarative/valuetypes/data/autoBindingRemoval.2.qml deleted file mode 100644 index ce2e82d..0000000 --- a/tests/auto/declarative/valuetypes/data/autoBindingRemoval.2.qml +++ /dev/null @@ -1,9 +0,0 @@ -import Test 1.0 - -MyTypeObject { - property int value: 10 - rect.x: value - - onRunScript: { rect = Qt.rect(10, 10, 10, 10) } -} - diff --git a/tests/auto/declarative/valuetypes/data/autoBindingRemoval.3.qml b/tests/auto/declarative/valuetypes/data/autoBindingRemoval.3.qml deleted file mode 100644 index c82b533..0000000 --- a/tests/auto/declarative/valuetypes/data/autoBindingRemoval.3.qml +++ /dev/null @@ -1,10 +0,0 @@ -import Test 1.0 - -MyTypeObject { - property var value - - rect: value - - onRunScript: { rect.x = 44 } -} - diff --git a/tests/auto/declarative/valuetypes/data/autoBindingRemoval.qml b/tests/auto/declarative/valuetypes/data/autoBindingRemoval.qml deleted file mode 100644 index a8a72f5..0000000 --- a/tests/auto/declarative/valuetypes/data/autoBindingRemoval.qml +++ /dev/null @@ -1,9 +0,0 @@ -import Test 1.0 - -MyTypeObject { - property int value: 10 - rect.x: value - - onRunScript: { rect.x = 42; } -} - diff --git a/tests/auto/declarative/valuetypes/data/bindingAssignment.qml b/tests/auto/declarative/valuetypes/data/bindingAssignment.qml deleted file mode 100644 index a652186..0000000 --- a/tests/auto/declarative/valuetypes/data/bindingAssignment.qml +++ /dev/null @@ -1,7 +0,0 @@ -import Test 1.0 - -MyTypeObject { - property int value: 10 - - rect.x: value -} diff --git a/tests/auto/declarative/valuetypes/data/bindingConflict.qml b/tests/auto/declarative/valuetypes/data/bindingConflict.qml deleted file mode 100644 index fd25c9f..0000000 --- a/tests/auto/declarative/valuetypes/data/bindingConflict.qml +++ /dev/null @@ -1,8 +0,0 @@ -import Test 1.0 - -MyTypeObject { - property int value: 13 - - rect.x: value - rect: "10,10,10x10" -} diff --git a/tests/auto/declarative/valuetypes/data/bindingRead.qml b/tests/auto/declarative/valuetypes/data/bindingRead.qml deleted file mode 100644 index 538d776..0000000 --- a/tests/auto/declarative/valuetypes/data/bindingRead.qml +++ /dev/null @@ -1,5 +0,0 @@ -import Test 1.0 - -MyTypeObject { - property int value: rect.x -} diff --git a/tests/auto/declarative/valuetypes/data/bindingVariantCopy.qml b/tests/auto/declarative/valuetypes/data/bindingVariantCopy.qml deleted file mode 100644 index 691a56c..0000000 --- a/tests/auto/declarative/valuetypes/data/bindingVariantCopy.qml +++ /dev/null @@ -1,13 +0,0 @@ -import Test 1.0 - -MyTypeObject { - property var object - object: MyTypeObject { - rect.x: 19 - rect.y: 33 - rect.width: 5 - rect.height: 99 - } - - rect: object.rect -} diff --git a/tests/auto/declarative/valuetypes/data/deletedObject.js b/tests/auto/declarative/valuetypes/data/deletedObject.js deleted file mode 100644 index af298ff..0000000 --- a/tests/auto/declarative/valuetypes/data/deletedObject.js +++ /dev/null @@ -1,13 +0,0 @@ -var savedReference; - -function startup() -{ - savedReference = object.rect; - console.log("Test: " + savedReference.x); -} - -function afterDelete() -{ - console.log("Test: " + savedReference.x); -} - diff --git a/tests/auto/declarative/valuetypes/data/deletedObject.qml b/tests/auto/declarative/valuetypes/data/deletedObject.qml deleted file mode 100644 index 05459f4..0000000 --- a/tests/auto/declarative/valuetypes/data/deletedObject.qml +++ /dev/null @@ -1,12 +0,0 @@ -import Test 1.0 -import Qt 4.6 - -MyTypeObject { - property var object - - Script { source: "deletedObject.js" } - - object: MyTypeObject {} - Component.onCompleted: startup() - onRunScript: afterDelete() -} diff --git a/tests/auto/declarative/valuetypes/data/font_read.qml b/tests/auto/declarative/valuetypes/data/font_read.qml deleted file mode 100644 index e1d1ce0..0000000 --- a/tests/auto/declarative/valuetypes/data/font_read.qml +++ /dev/null @@ -1,18 +0,0 @@ -import Test 1.0 - -MyTypeObject { - property string f_family: font.family - property bool f_bold: font.bold - property int f_weight: font.weight - property bool f_italic: font.italic - property bool f_underline: font.underline - property bool f_overline: font.overline - property bool f_strikeout: font.strikeout - property real f_pointSize: font.pointSize - property int f_pixelSize: font.pixelSize - property int f_capitalization: font.capitalization - property real f_letterSpacing: font.letterSpacing - property real f_wordSpacing: font.wordSpacing; - property var copy: font -} - diff --git a/tests/auto/declarative/valuetypes/data/font_write.2.qml b/tests/auto/declarative/valuetypes/data/font_write.2.qml deleted file mode 100644 index b559389..0000000 --- a/tests/auto/declarative/valuetypes/data/font_write.2.qml +++ /dev/null @@ -1,6 +0,0 @@ -import Test 1.0 - -MyTypeObject { - font.pixelSize: 10 -} - diff --git a/tests/auto/declarative/valuetypes/data/font_write.3.qml b/tests/auto/declarative/valuetypes/data/font_write.3.qml deleted file mode 100644 index 913ac50..0000000 --- a/tests/auto/declarative/valuetypes/data/font_write.3.qml +++ /dev/null @@ -1,7 +0,0 @@ -import Test 1.0 - -MyTypeObject { - font.pixelSize: 10 - font.pointSize: 19 -} - diff --git a/tests/auto/declarative/valuetypes/data/font_write.qml b/tests/auto/declarative/valuetypes/data/font_write.qml deleted file mode 100644 index ff4d0a1..0000000 --- a/tests/auto/declarative/valuetypes/data/font_write.qml +++ /dev/null @@ -1,16 +0,0 @@ -import Test 1.0 - -MyTypeObject { - font.family: if(1) "Helvetica" - font.bold: if(1) false - font.weight: "Normal" - font.italic: if(1) false - font.underline: if(1) false - font.overline: if(1) false - font.strikeout: if(1) false - font.pointSize: if(1) 15 - font.capitalization: "AllLowercase" - font.letterSpacing: if(1) 9.7 - font.wordSpacing: if(1) 11.2 -} - diff --git a/tests/auto/declarative/valuetypes/data/point_read.qml b/tests/auto/declarative/valuetypes/data/point_read.qml deleted file mode 100644 index 3e67de6..0000000 --- a/tests/auto/declarative/valuetypes/data/point_read.qml +++ /dev/null @@ -1,7 +0,0 @@ -import Test 1.0 - -MyTypeObject { - property int p_x: point.x - property int p_y: point.y - property var copy: point -} diff --git a/tests/auto/declarative/valuetypes/data/point_write.qml b/tests/auto/declarative/valuetypes/data/point_write.qml deleted file mode 100644 index 063525a..0000000 --- a/tests/auto/declarative/valuetypes/data/point_write.qml +++ /dev/null @@ -1,6 +0,0 @@ -import Test 1.0 - -MyTypeObject { - point.x: if (true) 11 - point.y: if (true) 12 -} diff --git a/tests/auto/declarative/valuetypes/data/pointf_read.qml b/tests/auto/declarative/valuetypes/data/pointf_read.qml deleted file mode 100644 index d845a5b..0000000 --- a/tests/auto/declarative/valuetypes/data/pointf_read.qml +++ /dev/null @@ -1,8 +0,0 @@ -import Test 1.0 - -MyTypeObject { - property real p_x: pointf.x - property real p_y: pointf.y - property var copy: pointf -} - diff --git a/tests/auto/declarative/valuetypes/data/pointf_write.qml b/tests/auto/declarative/valuetypes/data/pointf_write.qml deleted file mode 100644 index 9ee3fc1..0000000 --- a/tests/auto/declarative/valuetypes/data/pointf_write.qml +++ /dev/null @@ -1,6 +0,0 @@ -import Test 1.0 - -MyTypeObject { - pointf.x: if (true) 6.8 - pointf.y: if (true) 9.3 -} diff --git a/tests/auto/declarative/valuetypes/data/rect_read.qml b/tests/auto/declarative/valuetypes/data/rect_read.qml deleted file mode 100644 index 5364431..0000000 --- a/tests/auto/declarative/valuetypes/data/rect_read.qml +++ /dev/null @@ -1,10 +0,0 @@ -import Test 1.0 - -MyTypeObject { - property int r_x: rect.x - property int r_y: rect.y - property int r_width: rect.width - property int r_height: rect.height - property var copy: rect -} - diff --git a/tests/auto/declarative/valuetypes/data/rect_write.qml b/tests/auto/declarative/valuetypes/data/rect_write.qml deleted file mode 100644 index 8add453..0000000 --- a/tests/auto/declarative/valuetypes/data/rect_write.qml +++ /dev/null @@ -1,9 +0,0 @@ -import Test 1.0 - -MyTypeObject { - rect.x: if (true) 1234 - rect.y: if (true) 7 - rect.width: if (true) 56 - rect.height: if (true) 63 -} - diff --git a/tests/auto/declarative/valuetypes/data/rectf_read.qml b/tests/auto/declarative/valuetypes/data/rectf_read.qml deleted file mode 100644 index aeb9f41..0000000 --- a/tests/auto/declarative/valuetypes/data/rectf_read.qml +++ /dev/null @@ -1,10 +0,0 @@ -import Test 1.0 - -MyTypeObject { - property real r_x: rectf.x - property real r_y: rectf.y - property real r_width: rectf.width - property real r_height: rectf.height - property var copy: rectf -} - diff --git a/tests/auto/declarative/valuetypes/data/rectf_write.qml b/tests/auto/declarative/valuetypes/data/rectf_write.qml deleted file mode 100644 index 1e6ff4f..0000000 --- a/tests/auto/declarative/valuetypes/data/rectf_write.qml +++ /dev/null @@ -1,9 +0,0 @@ -import Test 1.0 - -MyTypeObject { - rectf.x: if (true) 70.1 - rectf.y: if (true) -113.2 - rectf.width: if (true) 80924.8 - rectf.height: if (true) 99.2 -} - diff --git a/tests/auto/declarative/valuetypes/data/scriptAccess.qml b/tests/auto/declarative/valuetypes/data/scriptAccess.qml deleted file mode 100644 index 96592eb..0000000 --- a/tests/auto/declarative/valuetypes/data/scriptAccess.qml +++ /dev/null @@ -1,9 +0,0 @@ -import Qt 4.6 -import Test 1.0 - -MyTypeObject { - property int valuePre; - property int valuePost; - - Component.onCompleted: { valuePre = rect.x; rect.x = 19; valuePost = rect.x; } -} diff --git a/tests/auto/declarative/valuetypes/data/scriptVariantCopy.qml b/tests/auto/declarative/valuetypes/data/scriptVariantCopy.qml deleted file mode 100644 index 29157e8..0000000 --- a/tests/auto/declarative/valuetypes/data/scriptVariantCopy.qml +++ /dev/null @@ -1,14 +0,0 @@ -import Test 1.0 - -MyTypeObject { - property var object - object: MyTypeObject { - rect.x: 19 - rect.y: 33 - rect.width: 5 - rect.height: 99 - } - - onRunScript: rect = object.rect -} - diff --git a/tests/auto/declarative/valuetypes/data/size_read.qml b/tests/auto/declarative/valuetypes/data/size_read.qml deleted file mode 100644 index 86dba03..0000000 --- a/tests/auto/declarative/valuetypes/data/size_read.qml +++ /dev/null @@ -1,8 +0,0 @@ -import Test 1.0 - -MyTypeObject { - property int s_width: size.width - property int s_height: size.height - property var copy: size -} - diff --git a/tests/auto/declarative/valuetypes/data/size_write.qml b/tests/auto/declarative/valuetypes/data/size_write.qml deleted file mode 100644 index 2f9d10e..0000000 --- a/tests/auto/declarative/valuetypes/data/size_write.qml +++ /dev/null @@ -1,7 +0,0 @@ -import Test 1.0 - -MyTypeObject { - size.width: if (true) 13 - size.height: if (true) 88 -} - diff --git a/tests/auto/declarative/valuetypes/data/sizef_read.qml b/tests/auto/declarative/valuetypes/data/sizef_read.qml deleted file mode 100644 index c6f34e4..0000000 --- a/tests/auto/declarative/valuetypes/data/sizef_read.qml +++ /dev/null @@ -1,9 +0,0 @@ -import Test 1.0 - -MyTypeObject { - property real s_width: sizef.width - property real s_height: sizef.height - property var copy: sizef -} - - diff --git a/tests/auto/declarative/valuetypes/data/sizef_write.qml b/tests/auto/declarative/valuetypes/data/sizef_write.qml deleted file mode 100644 index f16f0bd..0000000 --- a/tests/auto/declarative/valuetypes/data/sizef_write.qml +++ /dev/null @@ -1,6 +0,0 @@ -import Test 1.0 - -MyTypeObject { - sizef.width: if (true) 44.3 - sizef.height: if (true) 92.8 -} diff --git a/tests/auto/declarative/valuetypes/data/staticAssignment.qml b/tests/auto/declarative/valuetypes/data/staticAssignment.qml deleted file mode 100644 index b687f89..0000000 --- a/tests/auto/declarative/valuetypes/data/staticAssignment.qml +++ /dev/null @@ -1,5 +0,0 @@ -import Test 1.0 - -MyTypeObject { - rect.x: 9 -} diff --git a/tests/auto/declarative/valuetypes/data/valueInterceptors.qml b/tests/auto/declarative/valuetypes/data/valueInterceptors.qml deleted file mode 100644 index 026ae83..0000000 --- a/tests/auto/declarative/valuetypes/data/valueInterceptors.qml +++ /dev/null @@ -1,8 +0,0 @@ -import Test 1.0 - -MyTypeObject { - property int value: 13; - - rect.x: MyOffsetValueInterceptor {} - rect.x: value -} diff --git a/tests/auto/declarative/valuetypes/data/valueSources.qml b/tests/auto/declarative/valuetypes/data/valueSources.qml deleted file mode 100644 index d4d4391..0000000 --- a/tests/auto/declarative/valuetypes/data/valueSources.qml +++ /dev/null @@ -1,5 +0,0 @@ -import Test 1.0 - -MyTypeObject { - rect.x: MyConstantValueSource {} -} diff --git a/tests/auto/declarative/valuetypes/data/vector3d_read.qml b/tests/auto/declarative/valuetypes/data/vector3d_read.qml deleted file mode 100644 index abdf9f0..0000000 --- a/tests/auto/declarative/valuetypes/data/vector3d_read.qml +++ /dev/null @@ -1,9 +0,0 @@ -import Test 1.0 - -MyTypeObject { - property real v_x: vector.x - property real v_y: vector.y - property real v_z: vector.z - property var copy: vector -} - diff --git a/tests/auto/declarative/valuetypes/data/vector3d_write.qml b/tests/auto/declarative/valuetypes/data/vector3d_write.qml deleted file mode 100644 index 9c1bf76..0000000 --- a/tests/auto/declarative/valuetypes/data/vector3d_write.qml +++ /dev/null @@ -1,8 +0,0 @@ -import Test 1.0 - -MyTypeObject { - vector.x: if (true) -0.3 - vector.y: if (true) -12.9 - vector.z: if (true) 907.4 -} - diff --git a/tests/auto/declarative/valuetypes/testtypes.cpp b/tests/auto/declarative/valuetypes/testtypes.cpp deleted file mode 100644 index 565eb1c..0000000 --- a/tests/auto/declarative/valuetypes/testtypes.cpp +++ /dev/null @@ -1,45 +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 "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/valuetypes/testtypes.h b/tests/auto/declarative/valuetypes/testtypes.h deleted file mode 100644 index 67e32f5..0000000 --- a/tests/auto/declarative/valuetypes/testtypes.h +++ /dev/null @@ -1,152 +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$ -** -****************************************************************************/ -#ifndef TESTTYPES_H -#define TESTTYPES_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -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/valuetypes/tst_valuetypes.cpp b/tests/auto/declarative/valuetypes/tst_valuetypes.cpp deleted file mode 100644 index c3d08a2..0000000 --- a/tests/auto/declarative/valuetypes/tst_valuetypes.cpp +++ /dev/null @@ -1,588 +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 -#include -#include -#include -#include -#include "testtypes.h" - -class tst_valuetypes : public QObject -{ - Q_OBJECT -public: - tst_valuetypes() {} - -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_valuetypes::point() -{ - { - QmlComponent component(&engine, TEST_FILE("point_read.qml")); - MyTypeObject *object = qobject_cast(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(component.create()); - QVERIFY(object != 0); - - QCOMPARE(object->point(), QPoint(11, 12)); - - delete object; - } -} - -void tst_valuetypes::pointf() -{ - { - QmlComponent component(&engine, TEST_FILE("pointf_read.qml")); - MyTypeObject *object = qobject_cast(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(component.create()); - QVERIFY(object != 0); - - QCOMPARE(object->pointf(), QPointF(6.8, 9.3)); - - delete object; - } -} - -void tst_valuetypes::size() -{ - { - QmlComponent component(&engine, TEST_FILE("size_read.qml")); - MyTypeObject *object = qobject_cast(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(component.create()); - QVERIFY(object != 0); - - QCOMPARE(object->size(), QSize(13, 88)); - - delete object; - } -} - -void tst_valuetypes::sizef() -{ - { - QmlComponent component(&engine, TEST_FILE("sizef_read.qml")); - MyTypeObject *object = qobject_cast(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(component.create()); - QVERIFY(object != 0); - - QCOMPARE(object->sizef(), QSizeF(44.3, 92.8)); - - delete object; - } -} - -void tst_valuetypes::rect() -{ - { - QmlComponent component(&engine, TEST_FILE("rect_read.qml")); - MyTypeObject *object = qobject_cast(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(component.create()); - QVERIFY(object != 0); - - QCOMPARE(object->rect(), QRect(1234, 7, 56, 63)); - - delete object; - } -} - -void tst_valuetypes::rectf() -{ - { - QmlComponent component(&engine, TEST_FILE("rectf_read.qml")); - MyTypeObject *object = qobject_cast(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(component.create()); - QVERIFY(object != 0); - - QCOMPARE(object->rectf(), QRectF(70.1, -113.2, 80924.8, 99.2)); - - delete object; - } -} - -void tst_valuetypes::vector3d() -{ - { - QmlComponent component(&engine, TEST_FILE("vector3d_read.qml")); - MyTypeObject *object = qobject_cast(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(component.create()); - QVERIFY(object != 0); - - QCOMPARE(object->vector(), QVector3D(-0.3, -12.9, 907.4)); - - delete object; - } -} - -void tst_valuetypes::font() -{ - { - QmlComponent component(&engine, TEST_FILE("font_read.qml")); - MyTypeObject *object = qobject_cast(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(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(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(component.create()); - QVERIFY(object != 0); - - QCOMPARE(object->font().pixelSize(), 10); - - delete object; - } -} - -// Test bindings can write to value types -void tst_valuetypes::bindingAssignment() -{ - QmlComponent component(&engine, TEST_FILE("bindingAssignment.qml")); - MyTypeObject *object = qobject_cast(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_valuetypes::bindingRead() -{ - QmlComponent component(&engine, TEST_FILE("bindingRead.qml")); - MyTypeObject *object = qobject_cast(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_valuetypes::staticAssignment() -{ - QmlComponent component(&engine, TEST_FILE("staticAssignment.qml")); - MyTypeObject *object = qobject_cast(component.create()); - QVERIFY(object != 0); - - QCOMPARE(object->rect().x(), 9); - - delete object; -} - -// Test scripts can read/write value types -void tst_valuetypes::scriptAccess() -{ - QmlComponent component(&engine, TEST_FILE("scriptAccess.qml")); - MyTypeObject *object = qobject_cast(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_valuetypes::autoBindingRemoval() -{ - { - QmlComponent component(&engine, TEST_FILE("autoBindingRemoval.qml")); - MyTypeObject *object = qobject_cast(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(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(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_valuetypes::valueSources() -{ - QmlComponent component(&engine, TEST_FILE("valueSources.qml")); - MyTypeObject *object = qobject_cast(component.create()); - QVERIFY(object != 0); - - QCOMPARE(object->rect().x(), 3345); - - delete object; -} - -static void checkNoErrors(QmlComponent& component) -{ - QList 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_valuetypes::valueInterceptors() -{ - QmlComponent component(&engine, TEST_FILE("valueInterceptors.qml")); - MyTypeObject *object = qobject_cast(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_valuetypes::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_valuetypes::deletedObject() -{ - QmlComponent component(&engine, TEST_FILE("deletedObject.qml")); - QTest::ignoreMessage(QtDebugMsg, "Test: 2"); - MyTypeObject *object = qobject_cast(component.create()); - QVERIFY(object != 0); - - QObject *dObject = qvariant_cast(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_valuetypes::bindingVariantCopy() -{ - QmlComponent component(&engine, TEST_FILE("bindingVariantCopy.qml")); - MyTypeObject *object = qobject_cast(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_valuetypes::scriptVariantCopy() -{ - QmlComponent component(&engine, TEST_FILE("scriptVariantCopy.qml")); - MyTypeObject *object = qobject_cast(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_valuetypes::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_valuetypes) - -#include "tst_valuetypes.moc" diff --git a/tests/auto/declarative/valuetypes/valuetypes.pro b/tests/auto/declarative/valuetypes/valuetypes.pro deleted file mode 100644 index ae7c731..0000000 --- a/tests/auto/declarative/valuetypes/valuetypes.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_valuetypes.cpp \ - testtypes.cpp - -DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/xmlhttprequest/data/abort.expect b/tests/auto/declarative/xmlhttprequest/data/abort.expect deleted file mode 100644 index f43e043..0000000 --- a/tests/auto/declarative/xmlhttprequest/data/abort.expect +++ /dev/null @@ -1,10 +0,0 @@ -PUT /testdocument.html HTTP/1.1 -Content-Type: text/plain;charset=UTF-8 -Content-Length: 9 -Connection: Keep-Alive -Accept-Encoding: gzip -Accept-Language: en-US,* -User-Agent: Mozilla/5.0 -Host: 127.0.0.1:14445 - -Test Data \ No newline at end of file diff --git a/tests/auto/declarative/xmlhttprequest/data/abort.qml b/tests/auto/declarative/xmlhttprequest/data/abort.qml deleted file mode 100644 index d7b9266..0000000 --- a/tests/auto/declarative/xmlhttprequest/data/abort.qml +++ /dev/null @@ -1,42 +0,0 @@ -import Qt 4.6 - -QtObject { - property string urlDummy - property string url - - property bool seenDone: false - property bool didNotSeeUnsent: true - property bool endStateUnsent: false - property bool dataOK: false - - Component.onCompleted: { - var x = new XMLHttpRequest; - x.open("GET", urlDummy); - x.setRequestHeader("Test-header", "TestValue"); - x.send(); - - x.onreadystatechange = function() { - if (x.readyState == XMLHttpRequest.DONE) { - seenDone = true; - } else if (x.readyState == XMLHttpRequest.UNSENT) { - didNotSeeUnsent = false; - } - } - - x.abort(); - - if (x.readyState == XMLHttpRequest.UNSENT) { - endStateUnsent = true; - } - - x.onreadystatechange = function() { - if (x.readyState == XMLHttpRequest.DONE) { - dataOK = (x.responseText == "QML Rocks!\n"); - } - } - x.open("PUT", url); - x.send("Test Data"); - } -} - - diff --git a/tests/auto/declarative/xmlhttprequest/data/abort.reply b/tests/auto/declarative/xmlhttprequest/data/abort.reply deleted file mode 100644 index 35b11f4..0000000 --- a/tests/auto/declarative/xmlhttprequest/data/abort.reply +++ /dev/null @@ -1,2 +0,0 @@ -HTTP/1.0 200 OK -Content-type: text/html; charset=UTF-8 diff --git a/tests/auto/declarative/xmlhttprequest/data/abort_opened.qml b/tests/auto/declarative/xmlhttprequest/data/abort_opened.qml deleted file mode 100644 index 72a45e7..0000000 --- a/tests/auto/declarative/xmlhttprequest/data/abort_opened.qml +++ /dev/null @@ -1,58 +0,0 @@ -import Qt 4.6 - -QtObject { - property string url: "testdocument.html" - - property bool readyState: false - property bool openedState: false - - property bool status: false - property bool statusText: false - property bool responseText: false - property bool responseXML: false - - property bool dataOK: false - - Component.onCompleted: { - var x = new XMLHttpRequest; - x.abort(); - - if (x.readyState == XMLHttpRequest.UNSENT) - readyState = true; - - x.open("PUT", url); - - x.abort(); - - x.open("GET", url); - - if (x.readyState == XMLHttpRequest.OPENED) - openedState = true; - - try { - var a = x.status; - } catch (error) { - if (error.code == DOMException.INVALID_STATE_ERR) - status = true; - } - try { - var a = x.statusText; - } catch (error) { - if (error.code == DOMException.INVALID_STATE_ERR) - statusText = true; - } - responseText = (x.responseText == ""); - responseXML = (x.responseXML == null); - - // Test to the end - x.onreadystatechange = function() { - if (x.readyState == XMLHttpRequest.DONE) { - dataOK = (x.responseText == "QML Rocks!\n"); - } - } - - - x.send() - } -} - diff --git a/tests/auto/declarative/xmlhttprequest/data/abort_unsent.qml b/tests/auto/declarative/xmlhttprequest/data/abort_unsent.qml deleted file mode 100644 index aa78cde..0000000 --- a/tests/auto/declarative/xmlhttprequest/data/abort_unsent.qml +++ /dev/null @@ -1,54 +0,0 @@ -import Qt 4.6 - -QtObject { - property string url: "testdocument.html" - - property bool readyState: false - property bool openedState: false - - property bool status: false - property bool statusText: false - property bool responseText: false - property bool responseXML: false - - property bool dataOK: false - - Component.onCompleted: { - var x = new XMLHttpRequest; - x.abort(); - - if (x.readyState == XMLHttpRequest.UNSENT) - readyState = true; - - x.open("GET", url); - - if (x.readyState == XMLHttpRequest.OPENED) - openedState = true; - - try { - var a = x.status; - } catch (error) { - if (error.code == DOMException.INVALID_STATE_ERR) - status = true; - } - try { - var a = x.statusText; - } catch (error) { - if (error.code == DOMException.INVALID_STATE_ERR) - statusText = true; - } - responseText = (x.responseText == ""); - responseXML = (x.responseXML == null); - - // Test to the end - x.onreadystatechange = function() { - if (x.readyState == XMLHttpRequest.DONE) { - dataOK = (x.responseText == "QML Rocks!\n"); - } - } - - - x.send() - } -} - diff --git a/tests/auto/declarative/xmlhttprequest/data/attr.qml b/tests/auto/declarative/xmlhttprequest/data/attr.qml deleted file mode 100644 index 9049fc7..0000000 --- a/tests/auto/declarative/xmlhttprequest/data/attr.qml +++ /dev/null @@ -1,80 +0,0 @@ -import Qt 4.6 - -QtObject { - property bool xmlTest: false - property bool dataOK: false - - Script { - function checkAttr(documentElement, attr) - { - if (attr == null) - return; - - if (attr.name != "attr") - return; - - if (attr.value != "myvalue") - return; - - if (attr.ownerElement.tagName != documentElement.tagName) - return; - - if (attr.nodeName != "attr") - return; - - if (attr.nodeValue != "myvalue") - return; - - if (attr.nodeType != 2) - return; - - if (attr.childNodes.length != 0) - return; - - if (attr.firstChild != null) - return; - - if (attr.lastChild != null) - return; - - if (attr.previousSibling != null) - return; - - if (attr.nextSibling != null) - return; - - if (attr.attributes != null) - return; - - xmlTest = true; - } - - function checkXML(document) - { - checkAttr(document.documentElement, document.documentElement.attributes[0]); - } - } - - Component.onCompleted: { - var x = new XMLHttpRequest; - - x.open("GET", "attr.xml"); - - // Test to the end - x.onreadystatechange = function() { - if (x.readyState == XMLHttpRequest.DONE) { - - dataOK = true; - - if (x.responseXML != null) - checkXML(x.responseXML); - - } - } - - x.send() - } -} - - - diff --git a/tests/auto/declarative/xmlhttprequest/data/attr.xml b/tests/auto/declarative/xmlhttprequest/data/attr.xml deleted file mode 100644 index 2aa64a3..0000000 --- a/tests/auto/declarative/xmlhttprequest/data/attr.xml +++ /dev/null @@ -1 +0,0 @@ - diff --git a/tests/auto/declarative/xmlhttprequest/data/callbackException.qml b/tests/auto/declarative/xmlhttprequest/data/callbackException.qml deleted file mode 100644 index 9255922..0000000 --- a/tests/auto/declarative/xmlhttprequest/data/callbackException.qml +++ /dev/null @@ -1,25 +0,0 @@ -import Qt 4.6 - -QtObject { - id: obj - property string url - property string which - property bool threw: false - - onWhichChanged: { - var x = new XMLHttpRequest; - - x.onreadystatechange = function() { - if (x.readyState == which) { - obj.threw = true - throw(new Error("Exception from Callback")) - } - } - - x.open("GET", url); - x.setRequestHeader("Test-header", "TestValue"); - x.send(); - } -} - - diff --git a/tests/auto/declarative/xmlhttprequest/data/cdata.qml b/tests/auto/declarative/xmlhttprequest/data/cdata.qml deleted file mode 100644 index b2d0209..0000000 --- a/tests/auto/declarative/xmlhttprequest/data/cdata.qml +++ /dev/null @@ -1,135 +0,0 @@ -import Qt 4.6 - -QtObject { - property bool xmlTest: false - property bool dataOK: false - - Script { - function checkCData(text, whitespacetext) - { - // This is essentially a copy of text.qml/checkText() - - if (text == null) - return; - - if (text.nodeName != "#cdata-section") - return; - - if (text.nodeValue != "Hello world!") - return; - - if (text.nodeType != 4) - return; - - if (text.parentNode.nodeName != "item") - return; - - if (text.childNodes.length != 0) - return; - - if (text.firstChild != null) - return; - - if (text.lastChild != null) - return; - - if (text.previousSibling != null) - return; - - if (text.nextSibling != null) - return; - - if (text.attributes != null) - return; - - if (text.wholeText != "Hello world!") - return; - - if (text.data != "Hello world!") - return; - - if (text.length != 12) - return; - - if (text.isElementContentWhitespace != false) - return; - - if (whitespacetext.nodeName != "#cdata-section") - return; - - if (whitespacetext.nodeValue != " ") - return; - - if (whitespacetext.nodeType != 4) - return; - - if (whitespacetext.parentNode.nodeName != "item") - return; - - if (whitespacetext.childNodes.length != 0) - return; - - if (whitespacetext.firstChild != null) - return; - - if (whitespacetext.lastChild != null) - return; - - if (whitespacetext.previousSibling != null) - return; - - if (whitespacetext.nextSibling != null) - return; - - if (whitespacetext.attributes != null) - return; - - if (whitespacetext.wholeText != " ") - return; - - if (whitespacetext.data != " ") - return; - - if (whitespacetext.length != 3) - return; - - if (whitespacetext.isElementContentWhitespace != true) - return; - - - xmlTest = true; - } - - function checkXML(document) - { - checkCData(document.documentElement.childNodes[0].childNodes[0], - document.documentElement.childNodes[1].childNodes[0]); - - } - } - - Component.onCompleted: { - var x = new XMLHttpRequest; - - x.open("GET", "cdata.xml"); - - // Test to the end - x.onreadystatechange = function() { - if (x.readyState == XMLHttpRequest.DONE) { - - dataOK = true; - - if (x.responseXML != null) - checkXML(x.responseXML); - - } - } - - x.send() - } -} - - - - - diff --git a/tests/auto/declarative/xmlhttprequest/data/cdata.xml b/tests/auto/declarative/xmlhttprequest/data/cdata.xml deleted file mode 100644 index 061d37c..0000000 --- a/tests/auto/declarative/xmlhttprequest/data/cdata.xml +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/tests/auto/declarative/xmlhttprequest/data/constructor.qml b/tests/auto/declarative/xmlhttprequest/data/constructor.qml deleted file mode 100644 index 93e44fd..0000000 --- a/tests/auto/declarative/xmlhttprequest/data/constructor.qml +++ /dev/null @@ -1,14 +0,0 @@ -import Qt 4.6 - -QtObject { - property bool calledAsConstructor - property bool calledAsFunction - - Component.onCompleted: { - var x1 = new XMLHttpRequest; - var x2 = XMLHttpRequest(); - - calledAsConstructor = (x1 != null && x1 instanceof XMLHttpRequest); - calledAsFunction = (x2 == undefined); - } -} diff --git a/tests/auto/declarative/xmlhttprequest/data/defaultState.qml b/tests/auto/declarative/xmlhttprequest/data/defaultState.qml deleted file mode 100644 index 4dcf6f9..0000000 --- a/tests/auto/declarative/xmlhttprequest/data/defaultState.qml +++ /dev/null @@ -1,30 +0,0 @@ -import Qt 4.6 - -QtObject { - property int readyState - property bool statusIsException: false - property bool statusTextIsException: false - property string responseText - property bool responseXMLIsNull - - Component.onCompleted: { - var xhr = new XMLHttpRequest(); - - readyState = xhr.readyState; - try { - status = xhr.status; - } catch (error) { - if (error.code == DOMException.INVALID_STATE_ERR) - statusIsException = true; - } - try { - statusText = xhr.statusText; - } catch (error) { - if (error.code == DOMException.INVALID_STATE_ERR) - statusTextIsException = true; - } - responseText = xhr.responseText; - responseXMLIsNull = (xhr.responseXML == null); - } -} - diff --git a/tests/auto/declarative/xmlhttprequest/data/document.qml b/tests/auto/declarative/xmlhttprequest/data/document.qml deleted file mode 100644 index e372361..0000000 --- a/tests/auto/declarative/xmlhttprequest/data/document.qml +++ /dev/null @@ -1,58 +0,0 @@ -import Qt 4.6 - -QtObject { - property bool xmlTest: false - property bool dataOK: false - - Script { - function checkXML(document) - { - if (document.xmlVersion != "1.0") - return; - - if (document.xmlEncoding != "UTF-8") - return; - - if (document.xmlStandalone != true) - return; - - if (document.documentElement == null) - return; - - if (document.nodeName != "#document") - return; - - if (document.nodeValue != null) - return; - - if (document.parentNode != null) - return; - - // ### Test other node properties - // ### test encoding (what is a valid qt encoding?) - xmlTest = true; - } - } - - Component.onCompleted: { - var x = new XMLHttpRequest; - - x.open("GET", "document.xml"); - - // Test to the end - x.onreadystatechange = function() { - if (x.readyState == XMLHttpRequest.DONE) { - - dataOK = true; - - if (x.responseXML != null) - checkXML(x.responseXML); - - } - } - - x.send() - } -} - - diff --git a/tests/auto/declarative/xmlhttprequest/data/document.xml b/tests/auto/declarative/xmlhttprequest/data/document.xml deleted file mode 100644 index fb693ea..0000000 --- a/tests/auto/declarative/xmlhttprequest/data/document.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/tests/auto/declarative/xmlhttprequest/data/domExceptionCodes.qml b/tests/auto/declarative/xmlhttprequest/data/domExceptionCodes.qml deleted file mode 100644 index de5ee4f..0000000 --- a/tests/auto/declarative/xmlhttprequest/data/domExceptionCodes.qml +++ /dev/null @@ -1,60 +0,0 @@ -import Qt 4.6 - -QtObject { - property int index_size_err: DOMException.INDEX_SIZE_ERR - property int domstring_size_err: DOMException.DOMSTRING_SIZE_ERR - property int hierarchy_request_err: DOMException.HIERARCHY_REQUEST_ERR - property int wrong_document_err: DOMException.WRONG_DOCUMENT_ERR - property int invalid_character_err: DOMException.INVALID_CHARACTER_ERR - property int no_data_allowed_err: DOMException.NO_DATA_ALLOWED_ERR - property int no_modification_allowed_err: DOMException.NO_MODIFICATION_ALLOWED_ERR - property int not_found_err: DOMException.NOT_FOUND_ERR - property int not_supported_err: DOMException.NOT_SUPPORTED_ERR - property int inuse_attribute_err: DOMException.INUSE_ATTRIBUTE_ERR - property int invalid_state_err: DOMException.INVALID_STATE_ERR - property int syntax_err: DOMException.SYNTAX_ERR - property int invalid_modification_err: DOMException.INVALID_MODIFICATION_ERR - property int namespace_err: DOMException.NAMESPACE_ERR - property int invalid_access_err: DOMException.INVALID_ACCESS_ERR - property int validation_err: DOMException.VALIDATION_ERR - property int type_mismatch_err: DOMException.TYPE_MISMATCH_ERR - - Component.onCompleted: { - // Attempt to overwrite and delete values - DOMException.INDEX_SIZE_ERR = 44; - DOMException.DOMSTRING_SIZE_ERR = 44; - DOMException.HIERARCHY_REQUEST_ERR = 44; - DOMException.WRONG_DOCUMENT_ERR = 44; - DOMException.INVALID_CHARACTER_ERR = 44; - DOMException.NO_DATA_ALLOWED_ERR = 44; - DOMException.NO_MODIFICATION_ALLOWED_ERR = 44; - DOMException.NOT_FOUND_ERR = 44; - DOMException.NOT_SUPPORTED_ERR = 44; - DOMException.INUSE_ATTRIBUTE_ERR = 44; - DOMException.INVALID_STATE_ERR = 44; - DOMException.SYNTAX_ERR = 44; - DOMException.INVALID_MODIFICATION_ERR = 44; - DOMException.NAMESPACE_ERR = 44; - DOMException.INVALID_ACCESS_ERR = 44; - DOMException.VALIDATION_ERR = 44; - DOMException.TYPE_MISMATCH_ERR = 44; - - delete DOMException.INDEX_SIZE_ERR; - delete DOMException.DOMSTRING_SIZE_ERR; - delete DOMException.HIERARCHY_REQUEST_ERR; - delete DOMException.WRONG_DOCUMENT_ERR; - delete DOMException.INVALID_CHARACTER_ERR; - delete DOMException.NO_DATA_ALLOWED_ERR; - delete DOMException.NO_MODIFICATION_ALLOWED_ERR; - delete DOMException.NOT_FOUND_ERR; - delete DOMException.NOT_SUPPORTED_ERR; - delete DOMException.INUSE_ATTRIBUTE_ERR; - delete DOMException.INVALID_STATE_ERR; - delete DOMException.SYNTAX_ERR; - delete DOMException.INVALID_MODIFICATION_ERR; - delete DOMException.NAMESPACE_ERR; - delete DOMException.INVALID_ACCESS_ERR; - delete DOMException.VALIDATION_ERR; - delete DOMException.TYPE_MISMATCH_ERR; - } -} diff --git a/tests/auto/declarative/xmlhttprequest/data/element.qml b/tests/auto/declarative/xmlhttprequest/data/element.qml deleted file mode 100644 index 78c0374..0000000 --- a/tests/auto/declarative/xmlhttprequest/data/element.qml +++ /dev/null @@ -1,147 +0,0 @@ -import Qt 4.6 - -QtObject { - property bool xmlTest: false - property bool dataOK: false - - Script { - function checkElement(e, person, fruit) - { - if (e.tagName != "root") - return; - - if (e.nodeName != "root") - return; - - if (e.nodeValue != null) - return; - - if (e.nodeType != 1) - return; - - var childTagNames = [ "person", "fruit" ]; - - if (e.childNodes.length != childTagNames.length) - return; - - for (var ii = 0; ii < childTagNames.length; ++ii) { - if (e.childNodes[ii].tagName != childTagNames[ii]) - return; - } - - if (e.childNodes[childTagNames.length + 1] != null) - return; - - // Check writing fails - e.childNodes[0] = null; - if (e.childNodes[0] == null) - return; - - e.childNodes[10] = 10; - if (e.childNodes[10] != null) - return; - - if (e.firstChild.tagName != e.childNodes[0].tagName) - return; - - if (e.lastChild.tagName != e.childNodes[1].tagName) - return; - - if (e.previousSibling != null) - return; - - if (e.nextSibling != null) - return; - - if (e.attributes == null) - return; - - if (e.attributes.length != 2) - return; - - var attr1 = e.attributes["attr"]; - if (attr1.nodeValue != "value") - return; - - var attrIdx = e.attributes[0]; - if (attrIdx.nodeValue != "value") - return; - - var attr2 = e.attributes["attr2"]; - if (attr2.nodeValue != "value2") - return; - - var attr3 = e.attributes["attr3"]; - if (attr3 != null) - return; - - var attrIdx2 = e.attributes[11]; - if (attrIdx2 != null) - return; - - // Check writing fails - e.attributes[0] = null; - if (e.attributes[0] == null) - return; - - e.attributes["attr"] = null; - if (e.attributes["attr"] == null) - return; - - e.attributes["attr3"] = 10; - if (e.attributes["attr3"] != null) - return; - - // Check person and fruit sub elements - if (person.parentNode.nodeName != "root") - return; - - if (person.previousSibling != null) - return; - - if (person.nextSibling.nodeName != "fruit") - return; - - if (fruit.parentNode.nodeName != "root") - return; - - if (fruit.previousSibling.nodeName != "person") - return; - - if (fruit.nextSibling != null) - return; - - xmlTest = true; - } - - function checkXML(document) - { - checkElement(document.documentElement, - document.documentElement.childNodes[0], - document.documentElement.childNodes[1]); - } - } - - Component.onCompleted: { - var x = new XMLHttpRequest; - - x.open("GET", "element.xml"); - - // Test to the end - x.onreadystatechange = function() { - if (x.readyState == XMLHttpRequest.DONE) { - - dataOK = true; - - if (x.responseXML != null) - checkXML(x.responseXML); - - } - } - - x.send() - } -} - - - diff --git a/tests/auto/declarative/xmlhttprequest/data/element.xml b/tests/auto/declarative/xmlhttprequest/data/element.xml deleted file mode 100644 index 071ffae..0000000 --- a/tests/auto/declarative/xmlhttprequest/data/element.xml +++ /dev/null @@ -1 +0,0 @@ - diff --git a/tests/auto/declarative/xmlhttprequest/data/getAllResponseHeaders.qml b/tests/auto/declarative/xmlhttprequest/data/getAllResponseHeaders.qml deleted file mode 100644 index 02a8083..0000000 --- a/tests/auto/declarative/xmlhttprequest/data/getAllResponseHeaders.qml +++ /dev/null @@ -1,65 +0,0 @@ -import Qt 4.6 - -QtObject { - property string url - - property bool unsentException: false - property bool openedException: false - - property bool readyState: false - property bool openedState: false - - property bool headersReceivedState: false - property bool headersReceivedHeader: false - - property bool doneState: false - property bool doneHeader: false - - property bool dataOK: false - - Component.onCompleted: { - var x = new XMLHttpRequest; - - try { - x.getResponseHeader("Test-Header"); - } catch (e) { - if (e.code == DOMException.INVALID_STATE_ERR) - unsentException = true; - } - - if (x.readyState == XMLHttpRequest.UNSENT) - readyState = true; - - x.open("GET", url); - - if (x.readyState == XMLHttpRequest.OPENED) - openedState = true; - - try { - x.getResponseHeader("Test-Header"); - } catch (e) { - if (e.code == DOMException.INVALID_STATE_ERR) - openedException = true; - } - - var headers = "content-type: text/html; charset=UTF-8\r\ntest-header: TestValue\r\nmultitest-header: TestValue, SecondTestValue\r\ncontent-length: 11"; - - // Test to the end - x.onreadystatechange = function() { - if (x.readyState == XMLHttpRequest.HEADERS_RECEIVED) { - headersReceivedState = true; - - headersReceivedHeader = (x.getAllResponseHeaders() == headers); - } else if (x.readyState == XMLHttpRequest.DONE) { - doneState = headersReceivedState && true; - - doneHeader = (x.getAllResponseHeaders() == headers); - dataOK = (x.responseText == "QML Rocks!\n"); - } - } - - x.send() - } -} - - diff --git a/tests/auto/declarative/xmlhttprequest/data/getAllResponseHeaders_args.qml b/tests/auto/declarative/xmlhttprequest/data/getAllResponseHeaders_args.qml deleted file mode 100644 index 37124c7..0000000 --- a/tests/auto/declarative/xmlhttprequest/data/getAllResponseHeaders_args.qml +++ /dev/null @@ -1,23 +0,0 @@ -import Qt 4.6 - -QtObject { - property bool exceptionThrown: false - - Component.onCompleted: { - var x = new XMLHttpRequest; - - x.open("GET", "testdocument.html"); - x.send(); - - x.onreadystatechange = function() { - if (x.readyState == XMLHttpRequest.DONE) { - try { - x.getAllResponseHeaders("Test-header"); - } catch (e) { - if (e.code == DOMException.SYNTAX_ERR) - exceptionThrown = true; - } - } - } - } -} diff --git a/tests/auto/declarative/xmlhttprequest/data/getAllResponseHeaders_sent.qml b/tests/auto/declarative/xmlhttprequest/data/getAllResponseHeaders_sent.qml deleted file mode 100644 index 505e4b1..0000000 --- a/tests/auto/declarative/xmlhttprequest/data/getAllResponseHeaders_sent.qml +++ /dev/null @@ -1,20 +0,0 @@ -import Qt 4.6 - -QtObject { - property bool test: false - - Component.onCompleted: { - var x = new XMLHttpRequest; - - x.open("GET", "testdocument.html"); - x.send(); - - try { - x.getAllResponseHeaders(); - } catch (e) { - if (e.code == DOMException.INVALID_STATE_ERR) - test = true; - } - } -} - diff --git a/tests/auto/declarative/xmlhttprequest/data/getAllResponseHeaders_unsent.qml b/tests/auto/declarative/xmlhttprequest/data/getAllResponseHeaders_unsent.qml deleted file mode 100644 index 20fb040..0000000 --- a/tests/auto/declarative/xmlhttprequest/data/getAllResponseHeaders_unsent.qml +++ /dev/null @@ -1,16 +0,0 @@ -import Qt 4.6 - -QtObject { - property bool test: false - - Component.onCompleted: { - var x = new XMLHttpRequest; - - try { - x.getAllResponseHeaders(); - } catch (e) { - if (e.code == DOMException.INVALID_STATE_ERR) - test = true; - } - } -} diff --git a/tests/auto/declarative/xmlhttprequest/data/getResponseHeader.expect b/tests/auto/declarative/xmlhttprequest/data/getResponseHeader.expect deleted file mode 100644 index a740c79..0000000 --- a/tests/auto/declarative/xmlhttprequest/data/getResponseHeader.expect +++ /dev/null @@ -1,7 +0,0 @@ -GET /testdocument.html HTTP/1.1 -Connection: Keep-Alive -Accept-Encoding: gzip -Accept-Language: en-US,* -User-Agent: Mozilla/5.0 -Host: 127.0.0.1:14445 - diff --git a/tests/auto/declarative/xmlhttprequest/data/getResponseHeader.qml b/tests/auto/declarative/xmlhttprequest/data/getResponseHeader.qml deleted file mode 100644 index 2f949e1..0000000 --- a/tests/auto/declarative/xmlhttprequest/data/getResponseHeader.qml +++ /dev/null @@ -1,75 +0,0 @@ -import Qt 4.6 - -QtObject { - property string url - - property bool unsentException: false - property bool openedException: false - - property bool readyState: false - property bool openedState: false - - property bool headersReceivedState: false - property bool headersReceivedNullHeader: false - property bool headersReceivedValidHeader: false - property bool headersReceivedMultiValidHeader: false - property bool headersReceivedCookieHeader: false - - property bool doneState: false - property bool doneNullHeader: false - property bool doneValidHeader: false - property bool doneMultiValidHeader: false - property bool doneCookieHeader: false - - property bool dataOK: false - - Component.onCompleted: { - var x = new XMLHttpRequest; - - try { - x.getResponseHeader("Test-Header"); - } catch (e) { - if (e.code == DOMException.INVALID_STATE_ERR) - unsentException = true; - } - - if (x.readyState == XMLHttpRequest.UNSENT) - readyState = true; - - x.open("GET", url); - - if (x.readyState == XMLHttpRequest.OPENED) - openedState = true; - - try { - x.getResponseHeader("Test-Header"); - } catch (e) { - if (e.code == DOMException.INVALID_STATE_ERR) - openedException = true; - } - - // Test to the end - x.onreadystatechange = function() { - if (x.readyState == XMLHttpRequest.HEADERS_RECEIVED) { - headersReceivedState = true; - - headersReceivedNullHeader = (x.getResponseHeader("Nonexistant-header") == ""); - headersReceivedValidHeader = (x.getResponseHeader("Test-HEAder") == "TestValue"); - headersReceivedMultiValidHeader = (x.getResponseHeader("MultiTest-HEAder") == "TestValue, SecondTestValue"); - headersReceivedCookieHeader = (x.getResponseHeader("Set-Cookie") == "" && x.getResponseHeader("Set-Cookie2") == ""); - } else if (x.readyState == XMLHttpRequest.DONE) { - doneState = headersReceivedState && true; - - doneNullHeader = (x.getResponseHeader("Nonexistant-header") == ""); - doneValidHeader = (x.getResponseHeader("Test-HEAder") == "TestValue"); - doneMultiValidHeader = (x.getResponseHeader("MultiTest-HEAder") == "TestValue, SecondTestValue"); - doneCookieHeader = (x.getResponseHeader("Set-Cookie") == "" && x.getResponseHeader("Set-Cookie2") == ""); - dataOK = (x.responseText == "QML Rocks!\n"); - } - } - - x.send() - } -} - - diff --git a/tests/auto/declarative/xmlhttprequest/data/getResponseHeader.reply b/tests/auto/declarative/xmlhttprequest/data/getResponseHeader.reply deleted file mode 100644 index 62ec67b..0000000 --- a/tests/auto/declarative/xmlhttprequest/data/getResponseHeader.reply +++ /dev/null @@ -1,7 +0,0 @@ -HTTP/1.0 200 OK -Content-type: text/html; charset=UTF-8 -Test-Header: TestValue -MultiTest-Header: TestValue -MultiTest-Header: SecondTestValue -Set-Cookie: mycook=Value -Set-Cookie2: mycook=Value diff --git a/tests/auto/declarative/xmlhttprequest/data/getResponseHeader_args.qml b/tests/auto/declarative/xmlhttprequest/data/getResponseHeader_args.qml deleted file mode 100644 index d5aa4b1..0000000 --- a/tests/auto/declarative/xmlhttprequest/data/getResponseHeader_args.qml +++ /dev/null @@ -1,23 +0,0 @@ -import Qt 4.6 - -QtObject { - property bool exceptionThrown: false - - Component.onCompleted: { - var x = new XMLHttpRequest; - - x.open("GET", "testdocument.html"); - x.send(); - - x.onreadystatechange = function() { - if (x.readyState == XMLHttpRequest.DONE) { - try { - x.getResponseHeader(); - } catch (e) { - if (e.code == DOMException.SYNTAX_ERR) - exceptionThrown = true; - } - } - } - } -} diff --git a/tests/auto/declarative/xmlhttprequest/data/getResponseHeader_sent.qml b/tests/auto/declarative/xmlhttprequest/data/getResponseHeader_sent.qml deleted file mode 100644 index 7538ffd..0000000 --- a/tests/auto/declarative/xmlhttprequest/data/getResponseHeader_sent.qml +++ /dev/null @@ -1,20 +0,0 @@ -import Qt 4.6 - -QtObject { - property bool test: false - - Component.onCompleted: { - var x = new XMLHttpRequest; - - x.open("GET", "testdocument.html"); - x.send(); - - try { - x.getResponseHeader("Test-header"); - } catch (e) { - if (e.code == DOMException.INVALID_STATE_ERR) - test = true; - } - } -} - diff --git a/tests/auto/declarative/xmlhttprequest/data/getResponseHeader_unsent.qml b/tests/auto/declarative/xmlhttprequest/data/getResponseHeader_unsent.qml deleted file mode 100644 index 3b55802..0000000 --- a/tests/auto/declarative/xmlhttprequest/data/getResponseHeader_unsent.qml +++ /dev/null @@ -1,16 +0,0 @@ -import Qt 4.6 - -QtObject { - property bool test: false - - Component.onCompleted: { - var x = new XMLHttpRequest; - - try { - x.getResponseHeader("Test-header"); - } catch (e) { - if (e.code == DOMException.INVALID_STATE_ERR) - test = true; - } - } -} diff --git a/tests/auto/declarative/xmlhttprequest/data/instanceStateValues.qml b/tests/auto/declarative/xmlhttprequest/data/instanceStateValues.qml deleted file mode 100644 index b8d01c4..0000000 --- a/tests/auto/declarative/xmlhttprequest/data/instanceStateValues.qml +++ /dev/null @@ -1,33 +0,0 @@ -import Qt 4.6 - -QtObject { - property int unsent - property int opened - property int headers_received - property int loading - property int done - - Component.onCompleted: { - // Attempt to overwrite and delete values - var x = new XMLHttpRequest(); - - x.UNSENT = 9; - x.OPENED = 9; - x.HEADERS_RECEIVED = 9; - x.LOADING = 9; - x.DONE = 9; - - delete x.UNSENT; - delete x.OPENED; - delete x.HEADERS_RECEIVED; - delete x.LOADING; - delete x.DONE; - - unsent = x.UNSENT - opened = x.OPENED - headers_received = x.HEADERS_RECEIVED - loading = x.LOADING - done = x.DONE - } -} - diff --git a/tests/auto/declarative/xmlhttprequest/data/invalidMethodUsage.qml b/tests/auto/declarative/xmlhttprequest/data/invalidMethodUsage.qml deleted file mode 100644 index b30989b..0000000 --- a/tests/auto/declarative/xmlhttprequest/data/invalidMethodUsage.qml +++ /dev/null @@ -1,160 +0,0 @@ -import Qt 4.6 - -QtObject { - property bool onreadystatechange: false - property bool readyState: false - property bool status: false - property bool statusText: false - property bool responseText: false - property bool responseXML: false - - property bool open: false - property bool setRequestHeader: false - property bool send: false - property bool abort: false - property bool getResponseHeader: false - property bool getAllResponseHeaders: false - - Component.onCompleted: { - var o = 10; - - try { - XMLHttpRequest.prototype.onreadystatechange - } catch (e) { - if (!(e instanceof ReferenceError)) - return; - - if (e.message != "Not an XMLHttpRequest object") - return; - - onreadystatechange = true; - } - try { - XMLHttpRequest.prototype.readyState - } catch (e) { - if (!(e instanceof ReferenceError)) - return; - - if (e.message != "Not an XMLHttpRequest object") - return; - - readyState = true; - } - try { - XMLHttpRequest.prototype.status - } catch (e) { - if (!(e instanceof ReferenceError)) - return; - - if (e.message != "Not an XMLHttpRequest object") - return; - - status = true; - } - try { - XMLHttpRequest.prototype.statusText - } catch (e) { - if (!(e instanceof ReferenceError)) - return; - - if (e.message != "Not an XMLHttpRequest object") - return; - - statusText = true; - } - try { - XMLHttpRequest.prototype.responseText - } catch (e) { - if (!(e instanceof ReferenceError)) - return; - - if (e.message != "Not an XMLHttpRequest object") - return; - - responseText = true; - } - try { - XMLHttpRequest.prototype.responseXML - } catch (e) { - if (!(e instanceof ReferenceError)) - return; - - if (e.message != "Not an XMLHttpRequest object") - return; - - responseXML = true; - } - - try { - XMLHttpRequest.prototype.open.call(o); - } catch (e) { - if (!(e instanceof ReferenceError)) - return; - - if (e.message != "Not an XMLHttpRequest object") - return; - - open = true; - } - - try { - XMLHttpRequest.prototype.setRequestHeader.call(o); - } catch (e) { - if (!(e instanceof ReferenceError)) - return; - - if (e.message != "Not an XMLHttpRequest object") - return; - - setRequestHeader = true; - } - - try { - XMLHttpRequest.prototype.send.call(o); - } catch (e) { - if (!(e instanceof ReferenceError)) - return; - - if (e.message != "Not an XMLHttpRequest object") - return; - - send = true; - } - - try { - XMLHttpRequest.prototype.abort.call(o); - } catch (e) { - if (!(e instanceof ReferenceError)) - return; - - if (e.message != "Not an XMLHttpRequest object") - return; - - abort = true; - } - - try { - XMLHttpRequest.prototype.getResponseHeader.call(o); - } catch (e) { - if (!(e instanceof ReferenceError)) - return; - - if (e.message != "Not an XMLHttpRequest object") - return; - - getResponseHeader = true; - } - - try { - XMLHttpRequest.prototype.getAllResponseHeaders.call(o); - } catch (e) { - if (!(e instanceof ReferenceError)) - return; - - if (e.message != "Not an XMLHttpRequest object") - return; - - getAllResponseHeaders = true; - } - } -} diff --git a/tests/auto/declarative/xmlhttprequest/data/open.qml b/tests/auto/declarative/xmlhttprequest/data/open.qml deleted file mode 100644 index c06bae3..0000000 --- a/tests/auto/declarative/xmlhttprequest/data/open.qml +++ /dev/null @@ -1,53 +0,0 @@ -import Qt 4.6 - -QtObject { - property string url - - property bool readyState: false - property bool openedState: false - - property bool status: false - property bool statusText: false - property bool responseText: false - property bool responseXML: false - - property bool dataOK: false - - Component.onCompleted: { - var x = new XMLHttpRequest; - - if (x.readyState == XMLHttpRequest.UNSENT) - readyState = true; - - x.open("GET", url); - - if (x.readyState == XMLHttpRequest.OPENED) - openedState = true; - - try { - var a = x.status; - } catch (error) { - if (error.code == DOMException.INVALID_STATE_ERR) - status = true; - } - try { - var a = x.statusText; - } catch (error) { - if (error.code == DOMException.INVALID_STATE_ERR) - statusText = true; - } - responseText = (x.responseText == ""); - responseXML = (x.responseXML == null); - - // Test to the end - x.onreadystatechange = function() { - if (x.readyState == XMLHttpRequest.DONE) { - dataOK = (x.responseText == "QML Rocks!\n"); - } - } - - - x.send() - } -} - diff --git a/tests/auto/declarative/xmlhttprequest/data/open_arg_count.1.qml b/tests/auto/declarative/xmlhttprequest/data/open_arg_count.1.qml deleted file mode 100644 index b6d4c32..0000000 --- a/tests/auto/declarative/xmlhttprequest/data/open_arg_count.1.qml +++ /dev/null @@ -1,18 +0,0 @@ -import Qt 4.6 - -QtObject { - property bool exceptionThrown: false - - Component.onCompleted: { - var x = new XMLHttpRequest; - - try { - x.open("GET"); - } catch (e) { - if (e.code == DOMException.SYNTAX_ERR) - exceptionThrown = true; - } - } -} - - diff --git a/tests/auto/declarative/xmlhttprequest/data/open_arg_count.2.qml b/tests/auto/declarative/xmlhttprequest/data/open_arg_count.2.qml deleted file mode 100644 index 8c86c20..0000000 --- a/tests/auto/declarative/xmlhttprequest/data/open_arg_count.2.qml +++ /dev/null @@ -1,18 +0,0 @@ -import Qt 4.6 - -QtObject { - property bool exceptionThrown: false - - Component.onCompleted: { - var x = new XMLHttpRequest; - - try { - x.open("GET", "http://www.nokia.com", true, "user", "password", "extra"); - } catch (e) { - if (e.code == DOMException.SYNTAX_ERR) - exceptionThrown = true; - } - } -} - - diff --git a/tests/auto/declarative/xmlhttprequest/data/open_invalid_method.qml b/tests/auto/declarative/xmlhttprequest/data/open_invalid_method.qml deleted file mode 100644 index 69f79ae..0000000 --- a/tests/auto/declarative/xmlhttprequest/data/open_invalid_method.qml +++ /dev/null @@ -1,16 +0,0 @@ -import Qt 4.6 - -QtObject { - property bool exceptionThrown: false - - Component.onCompleted: { - var x = new XMLHttpRequest; - - try { - x.open("BLAH", "http://www.nokia.com"); - } catch (e) { - if (e.code == DOMException.SYNTAX_ERR) - exceptionThrown = true; - } - } -} diff --git a/tests/auto/declarative/xmlhttprequest/data/open_network.expect b/tests/auto/declarative/xmlhttprequest/data/open_network.expect deleted file mode 100644 index a740c79..0000000 --- a/tests/auto/declarative/xmlhttprequest/data/open_network.expect +++ /dev/null @@ -1,7 +0,0 @@ -GET /testdocument.html HTTP/1.1 -Connection: Keep-Alive -Accept-Encoding: gzip -Accept-Language: en-US,* -User-Agent: Mozilla/5.0 -Host: 127.0.0.1:14445 - diff --git a/tests/auto/declarative/xmlhttprequest/data/open_network.reply b/tests/auto/declarative/xmlhttprequest/data/open_network.reply deleted file mode 100644 index 35b11f4..0000000 --- a/tests/auto/declarative/xmlhttprequest/data/open_network.reply +++ /dev/null @@ -1,2 +0,0 @@ -HTTP/1.0 200 OK -Content-type: text/html; charset=UTF-8 diff --git a/tests/auto/declarative/xmlhttprequest/data/open_network.wait b/tests/auto/declarative/xmlhttprequest/data/open_network.wait deleted file mode 100644 index e69de29..0000000 diff --git a/tests/auto/declarative/xmlhttprequest/data/open_sync.qml b/tests/auto/declarative/xmlhttprequest/data/open_sync.qml deleted file mode 100644 index 1477279..0000000 --- a/tests/auto/declarative/xmlhttprequest/data/open_sync.qml +++ /dev/null @@ -1,17 +0,0 @@ -import Qt 4.6 - -QtObject { - property bool exceptionThrown: false - - Component.onCompleted: { - var x = new XMLHttpRequest; - - try { - x.open("GET", "http://www.nokia.com", false); - } catch (e) { - if (e.code == DOMException.NOT_SUPPORTED_ERR) - exceptionThrown = true; - } - } -} - diff --git a/tests/auto/declarative/xmlhttprequest/data/open_user.qml b/tests/auto/declarative/xmlhttprequest/data/open_user.qml deleted file mode 100644 index 19e37fa..0000000 --- a/tests/auto/declarative/xmlhttprequest/data/open_user.qml +++ /dev/null @@ -1,53 +0,0 @@ -import Qt 4.6 - -QtObject { - property string url - - property bool readyState: false - property bool openedState: false - - property bool status: false - property bool statusText: false - property bool responseText: false - property bool responseXML: false - - property bool dataOK: false - - Component.onCompleted: { - var x = new XMLHttpRequest; - - if (x.readyState == XMLHttpRequest.UNSENT) - readyState = true; - - x.open("GET", url, true, "username", "password"); - - if (x.readyState == XMLHttpRequest.OPENED) - openedState = true; - - try { - var a = x.status; - } catch (error) { - if (error.code == DOMException.INVALID_STATE_ERR) - status = true; - } - try { - var a = x.statusText; - } catch (error) { - if (error.code == DOMException.INVALID_STATE_ERR) - statusText = true; - } - responseText = (x.responseText == ""); - responseXML = (x.responseXML == null); - - // Test to the end - x.onreadystatechange = function() { - if (x.readyState == XMLHttpRequest.DONE) { - dataOK = (x.responseText == "QML Rocks!\n"); - } - } - - - x.send() - } -} - diff --git a/tests/auto/declarative/xmlhttprequest/data/open_username.qml b/tests/auto/declarative/xmlhttprequest/data/open_username.qml deleted file mode 100644 index 983ea14..0000000 --- a/tests/auto/declarative/xmlhttprequest/data/open_username.qml +++ /dev/null @@ -1,54 +0,0 @@ -import Qt 4.6 - -QtObject { - property string url - - property bool readyState: false - property bool openedState: false - - property bool status: false - property bool statusText: false - property bool responseText: false - property bool responseXML: false - - property bool dataOK: false - - Component.onCompleted: { - var x = new XMLHttpRequest; - - if (x.readyState == XMLHttpRequest.UNSENT) - readyState = true; - - x.open("GET", url, true, "sampleusername", "password"); - - if (x.readyState == XMLHttpRequest.OPENED) - openedState = true; - - try { - var a = x.status; - } catch (error) { - if (error.code == DOMException.INVALID_STATE_ERR) - status = true; - } - try { - var a = x.statusText; - } catch (error) { - if (error.code == DOMException.INVALID_STATE_ERR) - statusText = true; - } - responseText = (x.responseText == ""); - responseXML = (x.responseXML == null); - - // Test to the end - x.onreadystatechange = function() { - if (x.readyState == XMLHttpRequest.DONE) { - dataOK = (x.responseText == "QML Rocks!\n"); - } - } - - - x.send() - } -} - - diff --git a/tests/auto/declarative/xmlhttprequest/data/redirectError.qml b/tests/auto/declarative/xmlhttprequest/data/redirectError.qml deleted file mode 100644 index 6b345cc..0000000 --- a/tests/auto/declarative/xmlhttprequest/data/redirectError.qml +++ /dev/null @@ -1,23 +0,0 @@ -import Qt 4.6 - -QtObject { - property string url - - property bool dataOK: false - property bool done: false - - Component.onCompleted: { - var x = new XMLHttpRequest; - x.open("GET", url); - - x.onreadystatechange = function() { - if (x.readyState == XMLHttpRequest.DONE) { - done = true; - dataOK = x.status == 404; - } - } - - x.send(); - } -} - diff --git a/tests/auto/declarative/xmlhttprequest/data/redirectRecur.qml b/tests/auto/declarative/xmlhttprequest/data/redirectRecur.qml deleted file mode 100644 index c0321dc..0000000 --- a/tests/auto/declarative/xmlhttprequest/data/redirectRecur.qml +++ /dev/null @@ -1,23 +0,0 @@ -import Qt 4.6 - -QtObject { - property string url - - property bool dataOK: false - property bool done: false - - Component.onCompleted: { - var x = new XMLHttpRequest; - x.open("GET", url); - - x.onreadystatechange = function() { - if (x.readyState == XMLHttpRequest.DONE) { - done = true; - dataOK = x.status == 302; - } - } - - x.send(); - } -} - diff --git a/tests/auto/declarative/xmlhttprequest/data/redirects.qml b/tests/auto/declarative/xmlhttprequest/data/redirects.qml deleted file mode 100644 index f6fabdb..0000000 --- a/tests/auto/declarative/xmlhttprequest/data/redirects.qml +++ /dev/null @@ -1,22 +0,0 @@ -import Qt 4.6 - -QtObject { - property string url - - property bool dataOK: false - property bool done: false - - Component.onCompleted: { - var x = new XMLHttpRequest; - x.open("GET", url); - - x.onreadystatechange = function() { - if (x.readyState == XMLHttpRequest.DONE) { - done = true; - dataOK = x.responseText == "Redirected\n"; - } - } - - x.send(); - } -} diff --git a/tests/auto/declarative/xmlhttprequest/data/redirecttarget.html b/tests/auto/declarative/xmlhttprequest/data/redirecttarget.html deleted file mode 100644 index 95f35e0..0000000 --- a/tests/auto/declarative/xmlhttprequest/data/redirecttarget.html +++ /dev/null @@ -1 +0,0 @@ -Redirected diff --git a/tests/auto/declarative/xmlhttprequest/data/responseText.qml b/tests/auto/declarative/xmlhttprequest/data/responseText.qml deleted file mode 100644 index 4bb3a7a..0000000 --- a/tests/auto/declarative/xmlhttprequest/data/responseText.qml +++ /dev/null @@ -1,52 +0,0 @@ -import Qt 4.6 - -QtObject { - property string url - property string expectedText - - property bool unsent: false - property bool opened: false - property bool sent: false - property bool headersReceived: false - - property bool loading: false - property bool done: false - - property bool reset: false - - property bool dataOK: false - - Component.onCompleted: { - var x = new XMLHttpRequest; - - unsent = (x.responseText == ""); - - x.open("GET", url); - - opened = (x.responseText == ""); - - // Test to the end - x.onreadystatechange = function() { - if (x.readyState == XMLHttpRequest.HEADERS_RECEIVED) { - headersReceived = (x.responseText == ""); - } else if (x.readyState == XMLHttpRequest.LOADING) { - if (x.responseText == expectedText) - loading = true; - } else if (x.readyState == XMLHttpRequest.DONE) { - if (x.responseText == expectedText) - done = true; - - dataOK = (x.responseText == expectedText); - - x.open("GET", url); - - reset = (x.responseText == ""); - } - } - - x.send() - - sent = (x.responseText == ""); - } -} - diff --git a/tests/auto/declarative/xmlhttprequest/data/responseXML_invalid.qml b/tests/auto/declarative/xmlhttprequest/data/responseXML_invalid.qml deleted file mode 100644 index 63f288e..0000000 --- a/tests/auto/declarative/xmlhttprequest/data/responseXML_invalid.qml +++ /dev/null @@ -1,24 +0,0 @@ -import Qt 4.6 - -QtObject { - property bool xmlNull: false - property bool dataOK: false - - Component.onCompleted: { - var x = new XMLHttpRequest; - - x.open("GET", "testdocument.html"); - - // Test to the end - x.onreadystatechange = function() { - if (x.readyState == XMLHttpRequest.DONE) { - dataOK = (x.responseText == "QML Rocks!\n"); - xmlNull = (x.responseXML == null); - } - } - - - x.send() - } -} - diff --git a/tests/auto/declarative/xmlhttprequest/data/seconddocument.html b/tests/auto/declarative/xmlhttprequest/data/seconddocument.html deleted file mode 100644 index a33f44b..0000000 --- a/tests/auto/declarative/xmlhttprequest/data/seconddocument.html +++ /dev/null @@ -1 +0,0 @@ -This should not be read! diff --git a/tests/auto/declarative/xmlhttprequest/data/send_alreadySent.qml b/tests/auto/declarative/xmlhttprequest/data/send_alreadySent.qml deleted file mode 100644 index 0bad7df..0000000 --- a/tests/auto/declarative/xmlhttprequest/data/send_alreadySent.qml +++ /dev/null @@ -1,27 +0,0 @@ -import Qt 4.6 - -QtObject { - property bool dataOK: false - property bool test: false - - Component.onCompleted: { - var x = new XMLHttpRequest; - x.open("GET", "testdocument.html"); - - // Test to the end - x.onreadystatechange = function() { - if (x.readyState == XMLHttpRequest.DONE) { - dataOK = (x.responseText == "QML Rocks!\n"); - } - } - - x.send(); - - try { - x.send() - } catch (e) { - if (e.code == DOMException.INVALID_STATE_ERR) - test = true; - } - } -} diff --git a/tests/auto/declarative/xmlhttprequest/data/send_data.1.expect b/tests/auto/declarative/xmlhttprequest/data/send_data.1.expect deleted file mode 100644 index 81dd4a0..0000000 --- a/tests/auto/declarative/xmlhttprequest/data/send_data.1.expect +++ /dev/null @@ -1,10 +0,0 @@ -POST /testdocument.html HTTP/1.1 -Content-Type: text/plain;charset=UTF-8 -Content-Length: 12 -Connection: Keep-Alive -Accept-Encoding: gzip -Accept-Language: en-US,* -User-Agent: Mozilla/5.0 -Host: 127.0.0.1:14445 - -My Sent Data \ No newline at end of file diff --git a/tests/auto/declarative/xmlhttprequest/data/send_data.1.qml b/tests/auto/declarative/xmlhttprequest/data/send_data.1.qml deleted file mode 100644 index 03543a9..0000000 --- a/tests/auto/declarative/xmlhttprequest/data/send_data.1.qml +++ /dev/null @@ -1,21 +0,0 @@ -import Qt 4.6 - -QtObject { - property string url - - property bool dataOK: false - - Component.onCompleted: { - var x = new XMLHttpRequest; - x.open("POST", url); - - // Test to the end - x.onreadystatechange = function() { - if (x.readyState == XMLHttpRequest.DONE) { - dataOK = (x.responseText == "QML Rocks!\n"); - } - } - - x.send("My Sent Data"); - } -} diff --git a/tests/auto/declarative/xmlhttprequest/data/send_data.2.qml b/tests/auto/declarative/xmlhttprequest/data/send_data.2.qml deleted file mode 100644 index 79a27b6..0000000 --- a/tests/auto/declarative/xmlhttprequest/data/send_data.2.qml +++ /dev/null @@ -1,23 +0,0 @@ -import Qt 4.6 - -QtObject { - property string url - - property bool dataOK: false - - Component.onCompleted: { - var x = new XMLHttpRequest; - x.open("POST", url); - x.setRequestHeader("Content-Type", "text/plain;charset=UTF-8"); - - // Test to the end - x.onreadystatechange = function() { - if (x.readyState == XMLHttpRequest.DONE) { - dataOK = (x.responseText == "QML Rocks!\n"); - } - } - - x.send("My Sent Data"); - } -} - diff --git a/tests/auto/declarative/xmlhttprequest/data/send_data.3.qml b/tests/auto/declarative/xmlhttprequest/data/send_data.3.qml deleted file mode 100644 index e048769..0000000 --- a/tests/auto/declarative/xmlhttprequest/data/send_data.3.qml +++ /dev/null @@ -1,23 +0,0 @@ -import Qt 4.6 - -QtObject { - property string url - - property bool dataOK: false - - Component.onCompleted: { - var x = new XMLHttpRequest; - x.open("POST", url); - x.setRequestHeader("Content-Type", "text/plain;charset=latin1"); - - // Test to the end - x.onreadystatechange = function() { - if (x.readyState == XMLHttpRequest.DONE) { - dataOK = (x.responseText == "QML Rocks!\n"); - } - } - - x.send("My Sent Data"); - } -} - diff --git a/tests/auto/declarative/xmlhttprequest/data/send_data.4.expect b/tests/auto/declarative/xmlhttprequest/data/send_data.4.expect deleted file mode 100644 index 8fcf3ac..0000000 --- a/tests/auto/declarative/xmlhttprequest/data/send_data.4.expect +++ /dev/null @@ -1,10 +0,0 @@ -POST /testdocument.html HTTP/1.1 -Content-Type: charset=UTF-8;text/plain -Content-Length: 12 -Connection: Keep-Alive -Accept-Encoding: gzip -Accept-Language: en-US,* -User-Agent: Mozilla/5.0 -Host: 127.0.0.1:14445 - -My Sent Data \ No newline at end of file diff --git a/tests/auto/declarative/xmlhttprequest/data/send_data.4.qml b/tests/auto/declarative/xmlhttprequest/data/send_data.4.qml deleted file mode 100644 index 7ab0b27..0000000 --- a/tests/auto/declarative/xmlhttprequest/data/send_data.4.qml +++ /dev/null @@ -1,23 +0,0 @@ -import Qt 4.6 - -QtObject { - property string url - - property bool dataOK: false - - Component.onCompleted: { - var x = new XMLHttpRequest; - x.open("POST", url); - x.setRequestHeader("Content-Type", "charset=UTF-8;text/plain"); - - // Test to the end - x.onreadystatechange = function() { - if (x.readyState == XMLHttpRequest.DONE) { - dataOK = (x.responseText == "QML Rocks!\n"); - } - } - - x.send("My Sent Data"); - } -} - diff --git a/tests/auto/declarative/xmlhttprequest/data/send_data.5.qml b/tests/auto/declarative/xmlhttprequest/data/send_data.5.qml deleted file mode 100644 index 29bf2c2..0000000 --- a/tests/auto/declarative/xmlhttprequest/data/send_data.5.qml +++ /dev/null @@ -1,23 +0,0 @@ -import Qt 4.6 - -QtObject { - property string url - - property bool dataOK: false - - Component.onCompleted: { - var x = new XMLHttpRequest; - x.open("POST", url); - x.setRequestHeader("Content-Type", "charset=latin1;text/plain"); - - // Test to the end - x.onreadystatechange = function() { - if (x.readyState == XMLHttpRequest.DONE) { - dataOK = (x.responseText == "QML Rocks!\n"); - } - } - - x.send("My Sent Data"); - } -} - diff --git a/tests/auto/declarative/xmlhttprequest/data/send_data.6.expect b/tests/auto/declarative/xmlhttprequest/data/send_data.6.expect deleted file mode 100644 index 97e6fac..0000000 --- a/tests/auto/declarative/xmlhttprequest/data/send_data.6.expect +++ /dev/null @@ -1,10 +0,0 @@ -PUT /testdocument.html HTTP/1.1 -Content-Type: text/plain;charset=UTF-8 -Content-Length: 12 -Connection: Keep-Alive -Accept-Encoding: gzip -Accept-Language: en-US,* -User-Agent: Mozilla/5.0 -Host: 127.0.0.1:14445 - -My Sent Data \ No newline at end of file diff --git a/tests/auto/declarative/xmlhttprequest/data/send_data.6.qml b/tests/auto/declarative/xmlhttprequest/data/send_data.6.qml deleted file mode 100644 index 135f45c..0000000 --- a/tests/auto/declarative/xmlhttprequest/data/send_data.6.qml +++ /dev/null @@ -1,21 +0,0 @@ -import Qt 4.6 - -QtObject { - property string url - - property bool dataOK: false - - Component.onCompleted: { - var x = new XMLHttpRequest; - x.open("PUT", url); - - // Test to the end - x.onreadystatechange = function() { - if (x.readyState == XMLHttpRequest.DONE) { - dataOK = (x.responseText == "QML Rocks!\n"); - } - } - - x.send("My Sent Data"); - } -} diff --git a/tests/auto/declarative/xmlhttprequest/data/send_data.7.qml b/tests/auto/declarative/xmlhttprequest/data/send_data.7.qml deleted file mode 100644 index 4a09527..0000000 --- a/tests/auto/declarative/xmlhttprequest/data/send_data.7.qml +++ /dev/null @@ -1,23 +0,0 @@ -import Qt 4.6 - -QtObject { - property string url - - property bool dataOK: false - - Component.onCompleted: { - var x = new XMLHttpRequest; - x.open("POST", url); - x.setRequestHeader("Content-Type", "text/plain"); - - // Test to the end - x.onreadystatechange = function() { - if (x.readyState == XMLHttpRequest.DONE) { - dataOK = (x.responseText == "QML Rocks!\n"); - } - } - - x.send("My Sent Data"); - } -} - diff --git a/tests/auto/declarative/xmlhttprequest/data/send_data.reply b/tests/auto/declarative/xmlhttprequest/data/send_data.reply deleted file mode 100644 index 35b11f4..0000000 --- a/tests/auto/declarative/xmlhttprequest/data/send_data.reply +++ /dev/null @@ -1,2 +0,0 @@ -HTTP/1.0 200 OK -Content-type: text/html; charset=UTF-8 diff --git a/tests/auto/declarative/xmlhttprequest/data/send_ignoreData.qml b/tests/auto/declarative/xmlhttprequest/data/send_ignoreData.qml deleted file mode 100644 index dd5fa46..0000000 --- a/tests/auto/declarative/xmlhttprequest/data/send_ignoreData.qml +++ /dev/null @@ -1,26 +0,0 @@ -import Qt 4.6 - -QtObject { - property string reqType - property string url - - property bool dataOK: false - - Component.onCompleted: { - var x = new XMLHttpRequest; - x.open(reqType, url); - - // Test to the end - x.onreadystatechange = function() { - if (x.readyState == XMLHttpRequest.DONE) { - if (reqType == "HEAD") - dataOK = (x.responseText == ""); - else - dataOK = (x.responseText == "QML Rocks!\n"); - } - } - - x.send("Data To Ignore"); - } -} - diff --git a/tests/auto/declarative/xmlhttprequest/data/send_ignoreData.reply b/tests/auto/declarative/xmlhttprequest/data/send_ignoreData.reply deleted file mode 100644 index 35b11f4..0000000 --- a/tests/auto/declarative/xmlhttprequest/data/send_ignoreData.reply +++ /dev/null @@ -1,2 +0,0 @@ -HTTP/1.0 200 OK -Content-type: text/html; charset=UTF-8 diff --git a/tests/auto/declarative/xmlhttprequest/data/send_ignoreData_GET.expect b/tests/auto/declarative/xmlhttprequest/data/send_ignoreData_GET.expect deleted file mode 100644 index a740c79..0000000 --- a/tests/auto/declarative/xmlhttprequest/data/send_ignoreData_GET.expect +++ /dev/null @@ -1,7 +0,0 @@ -GET /testdocument.html HTTP/1.1 -Connection: Keep-Alive -Accept-Encoding: gzip -Accept-Language: en-US,* -User-Agent: Mozilla/5.0 -Host: 127.0.0.1:14445 - diff --git a/tests/auto/declarative/xmlhttprequest/data/send_ignoreData_PUT.expect b/tests/auto/declarative/xmlhttprequest/data/send_ignoreData_PUT.expect deleted file mode 100644 index 991bd59..0000000 --- a/tests/auto/declarative/xmlhttprequest/data/send_ignoreData_PUT.expect +++ /dev/null @@ -1,7 +0,0 @@ -HEAD /testdocument.html HTTP/1.1 -Connection: Keep-Alive -Accept-Encoding: gzip -Accept-Language: en-US,* -User-Agent: Mozilla/5.0 -Host: 127.0.0.1:14445 - diff --git a/tests/auto/declarative/xmlhttprequest/data/send_unsent.qml b/tests/auto/declarative/xmlhttprequest/data/send_unsent.qml deleted file mode 100644 index 7f51ecf..0000000 --- a/tests/auto/declarative/xmlhttprequest/data/send_unsent.qml +++ /dev/null @@ -1,16 +0,0 @@ -import Qt 4.6 - -QtObject { - property bool test: false - - Component.onCompleted: { - var x = new XMLHttpRequest; - - try { - x.send(); - } catch (e) { - if (e.code == DOMException.INVALID_STATE_ERR) - test = true; - } - } -} diff --git a/tests/auto/declarative/xmlhttprequest/data/setRequestHeader.expect b/tests/auto/declarative/xmlhttprequest/data/setRequestHeader.expect deleted file mode 100644 index 4600f2a..0000000 --- a/tests/auto/declarative/xmlhttprequest/data/setRequestHeader.expect +++ /dev/null @@ -1,9 +0,0 @@ -GET /testdocument.html HTTP/1.1 -TEST-HEADER: value -TEST-HEADER2: value,value2 -Connection: Keep-Alive -Accept-Encoding: gzip -Accept-Language: en-US,* -User-Agent: Mozilla/5.0 -Host: 127.0.0.1:14445 - diff --git a/tests/auto/declarative/xmlhttprequest/data/setRequestHeader.qml b/tests/auto/declarative/xmlhttprequest/data/setRequestHeader.qml deleted file mode 100644 index b0723aa..0000000 --- a/tests/auto/declarative/xmlhttprequest/data/setRequestHeader.qml +++ /dev/null @@ -1,28 +0,0 @@ -import Qt 4.6 - -QtObject { - property string url - - property bool dataOK: false - - Component.onCompleted: { - var x = new XMLHttpRequest; - - x.open("GET", url); - - x.setRequestHeader("Test-header", "value"); - x.setRequestHeader("Test-header2", "value"); - x.setRequestHeader("Test-header2", "value2"); - - // Test to the end - x.onreadystatechange = function() { - if (x.readyState == XMLHttpRequest.DONE) { - dataOK = (x.responseText == "QML Rocks!\n"); - } - } - - x.send(); - } -} - - diff --git a/tests/auto/declarative/xmlhttprequest/data/setRequestHeader.reply b/tests/auto/declarative/xmlhttprequest/data/setRequestHeader.reply deleted file mode 100644 index 35b11f4..0000000 --- a/tests/auto/declarative/xmlhttprequest/data/setRequestHeader.reply +++ /dev/null @@ -1,2 +0,0 @@ -HTTP/1.0 200 OK -Content-type: text/html; charset=UTF-8 diff --git a/tests/auto/declarative/xmlhttprequest/data/setRequestHeader_args.qml b/tests/auto/declarative/xmlhttprequest/data/setRequestHeader_args.qml deleted file mode 100644 index 8305ae1..0000000 --- a/tests/auto/declarative/xmlhttprequest/data/setRequestHeader_args.qml +++ /dev/null @@ -1,18 +0,0 @@ -import Qt 4.6 - -QtObject { - property bool exceptionThrown: false - - Component.onCompleted: { - var x = new XMLHttpRequest; - - x.open("GET", "testdocument.html"); - - try { - x.setRequestHeader("Test-header"); - } catch (e) { - if (e.code == DOMException.SYNTAX_ERR) - exceptionThrown = true; - } - } -} diff --git a/tests/auto/declarative/xmlhttprequest/data/setRequestHeader_illegalName.qml b/tests/auto/declarative/xmlhttprequest/data/setRequestHeader_illegalName.qml deleted file mode 100644 index bf31eca..0000000 --- a/tests/auto/declarative/xmlhttprequest/data/setRequestHeader_illegalName.qml +++ /dev/null @@ -1,57 +0,0 @@ -import Qt 4.6 - -QtObject { - property string url - property string header - - property bool readyState: false - property bool openedState: false - - property bool status: false - property bool statusText: false - property bool responseText: false - property bool responseXML: false - - property bool dataOK: false - - Component.onCompleted: { - var x = new XMLHttpRequest; - - if (x.readyState == XMLHttpRequest.UNSENT) - readyState = true; - - x.open("GET", url); - - x.setRequestHeader(header, "Value"); - - if (x.readyState == XMLHttpRequest.OPENED) - openedState = true; - - try { - var a = x.status; - } catch (error) { - if (error.code == DOMException.INVALID_STATE_ERR) - status = true; - } - try { - var a = x.statusText; - } catch (error) { - if (error.code == DOMException.INVALID_STATE_ERR) - statusText = true; - } - responseText = (x.responseText == ""); - responseXML = (x.responseXML == null); - - // Test to the end - x.onreadystatechange = function() { - if (x.readyState == XMLHttpRequest.DONE) { - dataOK = (x.responseText == "QML Rocks!\n"); - } - } - - - x.send() - } -} - - diff --git a/tests/auto/declarative/xmlhttprequest/data/setRequestHeader_sent.qml b/tests/auto/declarative/xmlhttprequest/data/setRequestHeader_sent.qml deleted file mode 100644 index c2bbc6e..0000000 --- a/tests/auto/declarative/xmlhttprequest/data/setRequestHeader_sent.qml +++ /dev/null @@ -1,31 +0,0 @@ -import Qt 4.6 - -QtObject { - property string url - property bool test: false - - property bool dataOK: false - - Component.onCompleted: { - var x = new XMLHttpRequest; - - x.open("GET", url); - - // Test to the end - x.onreadystatechange = function() { - if (x.readyState == XMLHttpRequest.DONE) { - dataOK = (x.responseText == "QML Rocks!\n"); - } - } - - x.send(); - - try { - x.setRequestHeader("Test-header", "value"); - } catch (e) { - if (e.code == DOMException.INVALID_STATE_ERR) - test = true; - } - } -} - diff --git a/tests/auto/declarative/xmlhttprequest/data/setRequestHeader_unsent.qml b/tests/auto/declarative/xmlhttprequest/data/setRequestHeader_unsent.qml deleted file mode 100644 index 30bc93e..0000000 --- a/tests/auto/declarative/xmlhttprequest/data/setRequestHeader_unsent.qml +++ /dev/null @@ -1,17 +0,0 @@ -import Qt 4.6 - -QtObject { - property bool test: false - - Component.onCompleted: { - var x = new XMLHttpRequest; - - try { - x.setRequestHeader("Test-header", "value"); - } catch (e) { - if (e.code == DOMException.INVALID_STATE_ERR) - test = true; - } - } -} - diff --git a/tests/auto/declarative/xmlhttprequest/data/staticStateValues.qml b/tests/auto/declarative/xmlhttprequest/data/staticStateValues.qml deleted file mode 100644 index ec1c5d8..0000000 --- a/tests/auto/declarative/xmlhttprequest/data/staticStateValues.qml +++ /dev/null @@ -1,24 +0,0 @@ -import Qt 4.6 - -QtObject { - property int unsent: XMLHttpRequest.UNSENT - property int opened: XMLHttpRequest.OPENED - property int headers_received: XMLHttpRequest.HEADERS_RECEIVED - property int loading: XMLHttpRequest.LOADING - property int done: XMLHttpRequest.DONE - - Component.onCompleted: { - // Attempt to overwrite and delete values - XMLHttpRequest.UNSENT = 9; - XMLHttpRequest.OPENED = 9; - XMLHttpRequest.HEADERS_RECEIVED = 9; - XMLHttpRequest.LOADING = 9; - XMLHttpRequest.DONE = 9; - - delete XMLHttpRequest.UNSENT; - delete XMLHttpRequest.OPENED; - delete XMLHttpRequest.HEADERS_RECEIVED; - delete XMLHttpRequest.LOADING; - delete XMLHttpRequest.DONE; - } -} diff --git a/tests/auto/declarative/xmlhttprequest/data/status.200.reply b/tests/auto/declarative/xmlhttprequest/data/status.200.reply deleted file mode 100644 index 35b11f4..0000000 --- a/tests/auto/declarative/xmlhttprequest/data/status.200.reply +++ /dev/null @@ -1,2 +0,0 @@ -HTTP/1.0 200 OK -Content-type: text/html; charset=UTF-8 diff --git a/tests/auto/declarative/xmlhttprequest/data/status.404.reply b/tests/auto/declarative/xmlhttprequest/data/status.404.reply deleted file mode 100644 index 964a7a8..0000000 --- a/tests/auto/declarative/xmlhttprequest/data/status.404.reply +++ /dev/null @@ -1,2 +0,0 @@ -HTTP/1.0 404 Document not found -Content-type: text/html; charset=UTF-8 diff --git a/tests/auto/declarative/xmlhttprequest/data/status.expect b/tests/auto/declarative/xmlhttprequest/data/status.expect deleted file mode 100644 index a740c79..0000000 --- a/tests/auto/declarative/xmlhttprequest/data/status.expect +++ /dev/null @@ -1,7 +0,0 @@ -GET /testdocument.html HTTP/1.1 -Connection: Keep-Alive -Accept-Encoding: gzip -Accept-Language: en-US,* -User-Agent: Mozilla/5.0 -Host: 127.0.0.1:14445 - diff --git a/tests/auto/declarative/xmlhttprequest/data/status.qml b/tests/auto/declarative/xmlhttprequest/data/status.qml deleted file mode 100644 index 04202c4..0000000 --- a/tests/auto/declarative/xmlhttprequest/data/status.qml +++ /dev/null @@ -1,77 +0,0 @@ -import Qt 4.6 - -QtObject { - property string url - property int expectedStatus - - property bool unsentException: false; - property bool openedException: false; - property bool sentException: false; - - property bool headersReceived: false - property bool loading: false - property bool done: false - - property bool resetException: false - - property bool dataOK: false - - Component.onCompleted: { - var x = new XMLHttpRequest; - - try { - var a = x.status; - } catch (e) { - if (e.code == DOMException.INVALID_STATE_ERR) - unsentException = true; - } - - x.open("GET", url); - - try { - var a = x.status; - } catch (e) { - if (e.code == DOMException.INVALID_STATE_ERR) - openedException = true; - } - - // Test to the end - x.onreadystatechange = function() { - if (x.readyState == XMLHttpRequest.HEADERS_RECEIVED) { - if (x.status == expectedStatus) - headersReceived = true; - } else if (x.readyState == XMLHttpRequest.LOADING) { - if (x.status == expectedStatus) - loading = true; - } else if (x.readyState == XMLHttpRequest.DONE) { - if (x.status == expectedStatus) - done = true; - - if (expectedStatus == 404) { - dataOK = (x.responseText == ""); - } else { - dataOK = (x.responseText == "QML Rocks!\n"); - } - - x.open("GET", url); - - try { - var a = x.status; - } catch (e) { - if (e.code == DOMException.INVALID_STATE_ERR) - resetException = true; - } - - } - } - - x.send() - - try { - var a = x.status; - } catch (e) { - if (e.code == DOMException.INVALID_STATE_ERR) - sentException = true; - } - } -} diff --git a/tests/auto/declarative/xmlhttprequest/data/statusText.qml b/tests/auto/declarative/xmlhttprequest/data/statusText.qml deleted file mode 100644 index 8becc3b..0000000 --- a/tests/auto/declarative/xmlhttprequest/data/statusText.qml +++ /dev/null @@ -1,77 +0,0 @@ -import Qt 4.6 - -QtObject { - property string url - property string expectedStatus - - property bool unsentException: false; - property bool openedException: false; - property bool sentException: false; - - property bool headersReceived: false - property bool loading: false - property bool done: false - - property bool resetException: false - - property bool dataOK: false - - Component.onCompleted: { - var x = new XMLHttpRequest; - - try { - var a = x.statusText; - } catch (e) { - if (e.code == DOMException.INVALID_STATE_ERR) - unsentException = true; - } - - x.open("GET", url); - - try { - var a = x.statusText; - } catch (e) { - if (e.code == DOMException.INVALID_STATE_ERR) - openedException = true; - } - - // Test to the end - x.onreadystatechange = function() { - if (x.readyState == XMLHttpRequest.HEADERS_RECEIVED) { - if (x.statusText == expectedStatus) - headersReceived = true; - } else if (x.readyState == XMLHttpRequest.LOADING) { - if (x.statusText == expectedStatus) - loading = true; - } else if (x.readyState == XMLHttpRequest.DONE) { - if (x.statusText == expectedStatus) - done = true; - - if (expectedStatus != "OK") { - dataOK = (x.responseText == ""); - } else { - dataOK = (x.responseText == "QML Rocks!\n"); - } - - x.open("GET", url); - - try { - var a = x.statusText; - } catch (e) { - if (e.code == DOMException.INVALID_STATE_ERR) - resetException = true; - } - - } - } - - x.send() - - try { - var a = x.statusText; - } catch (e) { - if (e.code == DOMException.INVALID_STATE_ERR) - sentException = true; - } - } -} diff --git a/tests/auto/declarative/xmlhttprequest/data/testdocument.html b/tests/auto/declarative/xmlhttprequest/data/testdocument.html deleted file mode 100644 index 8fe0f4b..0000000 --- a/tests/auto/declarative/xmlhttprequest/data/testdocument.html +++ /dev/null @@ -1 +0,0 @@ -QML Rocks! diff --git a/tests/auto/declarative/xmlhttprequest/data/text.qml b/tests/auto/declarative/xmlhttprequest/data/text.qml deleted file mode 100644 index 4615a07..0000000 --- a/tests/auto/declarative/xmlhttprequest/data/text.qml +++ /dev/null @@ -1,131 +0,0 @@ -import Qt 4.6 - -QtObject { - property bool xmlTest: false - property bool dataOK: false - - Script { - function checkText(text, whitespacetext) - { - if (text == null) - return; - - if (text.nodeName != "#text") - return; - - if (text.nodeValue != "Hello world!") - return; - - if (text.nodeType != 3) - return; - - if (text.parentNode.nodeName != "item") - return; - - if (text.childNodes.length != 0) - return; - - if (text.firstChild != null) - return; - - if (text.lastChild != null) - return; - - if (text.previousSibling != null) - return; - - if (text.nextSibling != null) - return; - - if (text.attributes != null) - return; - - if (text.wholeText != "Hello world!") - return; - - if (text.data != "Hello world!") - return; - - if (text.length != 12) - return; - - if (text.isElementContentWhitespace != false) - return; - - if (whitespacetext.nodeName != "#text") - return; - - if (whitespacetext.nodeValue != " ") - return; - - if (whitespacetext.nodeType != 3) - return; - - if (whitespacetext.parentNode.nodeName != "item") - return; - - if (whitespacetext.childNodes.length != 0) - return; - - if (whitespacetext.firstChild != null) - return; - - if (whitespacetext.lastChild != null) - return; - - if (whitespacetext.previousSibling != null) - return; - - if (whitespacetext.nextSibling != null) - return; - - if (whitespacetext.attributes != null) - return; - - if (whitespacetext.wholeText != " ") - return; - - if (whitespacetext.data != " ") - return; - - if (whitespacetext.length != 3) - return; - - if (whitespacetext.isElementContentWhitespace != true) - return; - - xmlTest = true; - } - - function checkXML(document) - { - checkText(document.documentElement.childNodes[0].childNodes[0], - document.documentElement.childNodes[1].childNodes[0]); - - } - } - - Component.onCompleted: { - var x = new XMLHttpRequest; - - x.open("GET", "text.xml"); - - // Test to the end - x.onreadystatechange = function() { - if (x.readyState == XMLHttpRequest.DONE) { - - dataOK = true; - - if (x.responseXML != null) - checkXML(x.responseXML); - - } - } - - x.send() - } -} - - - - diff --git a/tests/auto/declarative/xmlhttprequest/data/text.xml b/tests/auto/declarative/xmlhttprequest/data/text.xml deleted file mode 100644 index e741688..0000000 --- a/tests/auto/declarative/xmlhttprequest/data/text.xml +++ /dev/null @@ -1 +0,0 @@ -Hello world! diff --git a/tests/auto/declarative/xmlhttprequest/tst_xmlhttprequest.cpp b/tests/auto/declarative/xmlhttprequest/tst_xmlhttprequest.cpp deleted file mode 100644 index 253e041..0000000 --- a/tests/auto/declarative/xmlhttprequest/tst_xmlhttprequest.cpp +++ /dev/null @@ -1,1315 +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 -#include -#include -#include -#include -#include "testhttpserver.h" - -#define SERVER_PORT 14445 - -class tst_xmlhttprequest : public QObject -{ - Q_OBJECT -public: - tst_xmlhttprequest() {} - -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_xmlhttprequest::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_xmlhttprequest::callbackException_data() -{ - QTest::addColumn("which"); - QTest::addColumn("line"); - - QTest::newRow("on-opened") << "1" << 15; - QTest::newRow("on-loading") << "3" << 15; - QTest::newRow("on-done") << "4" << 15; -} - -void tst_xmlhttprequest::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_xmlhttprequest::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_xmlhttprequest::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_xmlhttprequest::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_xmlhttprequest::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_xmlhttprequest::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_xmlhttprequest::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_xmlhttprequest::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_xmlhttprequest::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_xmlhttprequest::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_xmlhttprequest::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_xmlhttprequest::setRequestHeader_illegalName_data() -{ - QTest::addColumn("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_xmlhttprequest::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_xmlhttprequest::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_xmlhttprequest::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_xmlhttprequest::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_xmlhttprequest::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_xmlhttprequest::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_xmlhttprequest::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_xmlhttprequest::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_xmlhttprequest::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_xmlhttprequest::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_xmlhttprequest::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_xmlhttprequest::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_xmlhttprequest::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_xmlhttprequest::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_xmlhttprequest::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_xmlhttprequest::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_xmlhttprequest::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_xmlhttprequest::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_xmlhttprequest::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_xmlhttprequest::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_xmlhttprequest::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_xmlhttprequest::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_xmlhttprequest::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_xmlhttprequest::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_xmlhttprequest::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_xmlhttprequest::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_xmlhttprequest::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_xmlhttprequest::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_xmlhttprequest::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_xmlhttprequest) - -#include "tst_xmlhttprequest.moc" diff --git a/tests/auto/declarative/xmlhttprequest/xmlhttprequest.pro b/tests/auto/declarative/xmlhttprequest/xmlhttprequest.pro deleted file mode 100644 index 1da28e5..0000000 --- a/tests/auto/declarative/xmlhttprequest/xmlhttprequest.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_xmlhttprequest.cpp \ - ../shared/testhttpserver.cpp - - -# Define SRCDIR equal to test's source directory -DEFINES += SRCDIR=\\\"$$PWD\\\" -- cgit v0.12